stockfish.js icon indicating copy to clipboard operation
stockfish.js copied to clipboard

Set up CORS for stockfish-nnue-16.js

Open muhammadanasajjad opened this issue 2 years ago • 1 comments

After having read: "The full mult-threaded engine:

  • This is best version of the engine but will only run in new browsers with the proper CORS headers applied.

  • Files: stockfish-nnue-16.js & stockfish-nnue-16.wasm"

I would like to know what the proper CORS headers are and how to set them up? Or is the issue that I am running on localhost?

Thanks in advance😃

muhammadanasajjad avatar Dec 20 '23 23:12 muhammadanasajjad

You can get the answer in the example folder : https://github.com/nmrugg/stockfish.js/blob/bb8d0c38ef5512a4825021a50d5951fca22b22b1/example/server.js#L127

You must add those two headers for requests serving your app page & the stockfish-nnue-16.js file :

resHeaders["Cross-Origin-Embedder-Policy"] = "require-corp";
resHeaders["Cross-Origin-Opener-Policy"] = "same-origin";

GuillaumeSD avatar Mar 21 '24 00:03 GuillaumeSD