javascriptreactjswebassemblysharedarraybufferffmpeg-wasm

"SharedArrayBuffer is not defined" error in cloud server but working in localhost


I have enable SharedArrayBuffer and was working in my localhost but once i pushed it to testing environment it is not working.

I added these cors headers to enable SharedArrayBuffer

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

Our testing env does not use Nginx or any other loadbalancer, I am also adding curl -I results of both my localhost and server. Both are same BTW.

localhost:

X-Powered-By: Express
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Content-Type: text/html; charset=utf-8
Content-Length: 6293
ETag: W/"1895-PaoXXUQuEWUDQDGVTFEVesWjsgU"
Vary: Accept-Encoding
Date: Wed, 30 Nov 2022 07:00:32 GMT
Connection: keep-alive
Keep-Alive: timeout=5

cloud server:

X-Powered-By: Express
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Content-Type: text/html; charset=utf-8
Content-Length: 6293
ETag: W/"1895-NZTN58jpvKWWO2z5SgAnAyNn4Tk"
Vary: Accept-Encoding
Date: Wed, 30 Nov 2022 06:59:55 GMT
Connection: keep-alive
Keep-Alive: timeout=5

Is there anything i need to add in cloud provider(Azure) or anywhere. PS: I am trying to use ffmpeg.wasm and tested using Firefox, chrome and edge.

Tried adding Cross-Origin-Resource-Policy: cross-origin but it is not related to that.


Solution

  • The issue is Https. SharedArrayBuffer will not work on http after adding https it worked. Not removing this question it might help someone in future.