1

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"
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Spiri
  • 331
  • 2
  • 9

1 Answers1

2

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.

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Spiri
  • 331
  • 2
  • 9
  • 1
    Specifying `Access-Control-Allow-Origin "*"` allows all origins. You should specify the origin. Do not use wildcards for origin otherwise, you have a CORS policy that protects nothing. – John Hanley May 14 '23 at 16:53
  • You're right! At first I was just happy to have finally managed to do it after a long time. All in all, I learned a lot from it. Now I can make it specific instead "*" – Spiri May 16 '23 at 10:32