ubuntuapache2sharedarraybuffer

Enabling cross-origin isolation on the apache2 web server


My system is Ubuntu and i use the apache2 web server. I need SharedArrayBuffer in my site. But when I call my page I get the error:

"Uncaught (in promise) ReferenceError: SharedArrayBuffer is not defined"

Solution

  • Well, I did some research and quickly found out that I had to add the following to the header:

    Cross-Origin-Opener-Policy: same-origin
    Cross-Origin-Embedder-Policy: require-corp
    

    Now digging further.

    in the console:

    sudo nano /etc/apache2/apache2.conf
    

    and changed AllowOverride None in AllowOverride All

    <Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All       
    Require all granted
    </Directory>
    

    enabled mod headers

    sudo a2enmod headers
    

    then i restarted the apache2 server

    sudo systemctl restart apache2
    

    created in var/www:

    .htaccess

    Header set Access-Control-Allow-Origin "*"
    Header set Cross-Origin-Opener-Policy: same-origin
    Header set Cross-Origin-Embedder-Policy: require-corp
    
    

    So now I have a cross origin isolated page.