Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS fails on Firefox #6

Closed
NeoCoderMatrix86 opened this issue Mar 3, 2021 · 8 comments
Closed

CORS fails on Firefox #6

NeoCoderMatrix86 opened this issue Mar 3, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@NeoCoderMatrix86
Copy link

On Firefox I can not use the library because of bad CORS:

Quellübergreifende (Cross-Origin) Anfrage blockiert: Die Gleiche-Quelle-Regel verbietet das Lesen der externen Ressource auf https://unpkg.com/@ffmpeg/ffmpeg@0.9.7/dist/ffmpeg.min.js. (Grund: CORS-Anfrage schlug fehl).

Modul-Quell-URI ist in diesem Dokument nicht erlaubt: "https://unpkg.com/@ffmpeg/ffmpeg@0.9.7/dist/ffmpeg.min.js".

How can this be fixed?

@sps014
Copy link
Owner

sps014 commented Mar 3, 2021

Hi,
I tested my sample site on Firefox, SharedArrayBuffer was main cultprit.
It turns out that the base Repo FFmpeg Wasm Sample had the same issue.

Can you please report there.
If it will be fixed there, it won't take long for me to fix it here as well.
Currently only Chromium doesn't enforce SharedArrayBuffer CORS header restriction , however this will also change in future.
The original issue is here.

@NeoCoderMatrix86
Copy link
Author

Thanks for your investigation. I opened up ffmpegwasm/ffmpeg.wasm#166

In Blazor assemblies it is common that you include all javascript required in wwwroot, why not just use this?

@sps014 sps014 assigned sps014 and unassigned sps014 Mar 4, 2021
@sps014 sps014 added the enhancement New feature or request label Mar 4, 2021
@sps014
Copy link
Owner

sps014 commented Mar 4, 2021

Great suggestion,
I will definitely explore self host option in upcoming releases.

@sps014 sps014 closed this as completed Mar 7, 2021
@NeoCoderMatrix86
Copy link
Author

Just for your information: https://github.com/ffmpegwasm/ffmpeg.wasm is an experimental project. The CORS problem will be much greater in May, because Chrome (and therefore Edge because it is build on top of it) will drop support for SharedArrayBuffer. Having this in mind, I dropped this library out of my project in short term and will have a look for anther solution (production stable) in long term. As mentioned here ffmpegwasm/ffmpeg.wasm#166 (comment) maybe you can have a version with ffmpeg.js.

@sps014
Copy link
Owner

sps014 commented Mar 11, 2021

I don't think sharedArrayBuffer will be dropped any time soon , Blazor folks are using sharedArrayBuffer to implement multi threading in WASM.
I am experimenting in this branch.
Here is good article by Uno team explaining the changes in WASM in 2021.

@sps014
Copy link
Owner

sps014 commented Mar 11, 2021

Hey Netlify allows adding custom headers ,
Netlify is free , similar to Github pages.

Steps:

  1. build this branch (https://github.com/sps014/FFmpegBlazor/tree/Self-Host).
  2. add reference of ffmpeg library to your project
  3. publish to netlify
  4. add custom header
    Header set Cross-Origin-Opener-Policy: same-origin
    Header set Cross-Origin-Embedder-Policy: require-corp
    to wasm route https://yourpage.com/_content/FFmpegBlazor/0.8.5/dist/ffmpeg-core.wasm
    replace yourpage.com to your netlify app address

@NeoCoderMatrix86
Copy link
Author

Well, I'm currently not planning to move to Netlify. Maybe in future, but currently I'm facing to much bugs and need to fix them first. If the library works on all major browsers, I will defently use it, but currently it is to unstable for my approach. I will come here later and see how the next version performs :).

@Aloento
Copy link

Aloento commented Nov 22, 2021

This problem is even more significant today and I think it should be depreciated ffmpeg.wasm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants