Is it possible to set custom headers on CodeSandbox?

89 views Asked by At

As the title states, I'm wondering if it's possible to set custom headers on CodeSandbox. Specifically, I'm trying to get ffmpeg.wasm to run on CodeSandbox. Currently, for ffmpeg.wasm to work in the browser (i.e. outside a Node environment), one needs to add the following headers:

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

On static site servers (ex. Netlify, Vercel, etc.) this is possible, but I haven't had any success finding a way to do it on CodeSandbox. Maybe there just isn't a way yet :)

So, is there a way to set custom headers somewhere in CodeSandbox? I see there are ways to change the sandbox template and environment, but nothing so low-level as being able to set what headers are set in the sandbox. I'd appreciate any pointers here.

I posted nearly the same question within the discussions section of CodeSandbox's GitHub: https://github.com/codesandbox/codesandbox-client/discussions/7253

1

There are 1 answers

0
fullStackChris On BEST ANSWER

As of December 2022, custom headers are not supported in CodeSandbox. In our case, we are going to move forward using GitHub Pages as our demo site, they support setting custom headers:

https://docs.github.com/en/[email protected]/admin/configuration/configuring-your-enterprise/configuring-github-pages-for-your-enterprise#configuring-github-pages-response-headers-for-your-enterprise