Closed arjun-digi closed 6 months ago
Hey @arjun-digi , I had a brief look at Lighttpd configuration docs, if I got it right to set custom headers one needs the mod_setenv module, which seems to be a built-in. Thus to use it you need to add its init here prior to building your project, and then use extraConfig
option of the server constructor to load & configure it as you need. If you can try it locally and confirm it works for you, I'll add the PLUGIN_INIT(mod_setenv)
to the CMakeList.txt in the next release.
Hey @birdofpreyru,
Thank you for your quick response on this. I've implemented the changes as per your instructions, and it seems to be working for me! If I got you right, below are the changes I made in the CMakeLists.txt and the extraConfig option:
In CMakeLists.txt:
set(PLUGIN_STATIC
PLUGIN_INIT(mod_alias)\n
PLUGIN_INIT(mod_dirlisting)\n
PLUGIN_INIT(mod_h2)\n
PLUGIN_INIT(mod_indexfile)\n
PLUGIN_INIT(mod_rewrite)\n
PLUGIN_INIT(mod_staticfile)\n
PLUGIN_INIT(mod_setenv)\n
)
in extraConfig block:
extraConfig: `
server.modules += ("mod_alias", "mod_rewrite", "mod_setenv")
setenv.add-response-header = (
"Cross-Origin-Embedder-Policy" => "require-corp"
"Cross-Origin-Opener-Policy" => "same-origin"
)
alias.url = (
"/some/path" => "${fileDir}"
)
url.rewrite-once = ( "/bad/path/(.*)" => "/$1" )
`,
After making these changes, the server is running smoothly with the custom headers set as expected. Thank you again for your guidance! Let me know if you need any further information or if there's anything else I can assist with.
However I am still looking how to communicate with stockfish.js using static server.
After making these changes, the server is running smoothly with the custom headers set as expected.
Great! As I told, I'll make this update to CMakeList.txt in the next library release (not sure when exactly, probably not right away).
However I am still looking how to communicate with stockfish.js using static server.
Well... good luck with it, I guess... because if it is a question, I don't know how to communicate with stockfish.js, I don't know what exactly stockfish.js is, and I see no reason for me to learn about it now :)
Problem The current implementation in the React Native application involves serving static files from a local/static server, including an index.html file with embedded JavaScript code. Although the React Native application successfully connects to the server and fetches the index.html file, it fails to properly handle the custom headers required for communication with the stockfish.js file.
Expected Behavior The React Native application should serve static files, including the index.html file, with the necessary custom headers to facilitate communication with the stockfish.js file and retrieve the expected data.
Current Setup The React Native application connects to a local/static server. Utilizes the JavaScript fetch method to retrieve the index.html file. The index.html file contains embedded JavaScript code, dependent on two additional files: stockfish.js and stockfish.wasm.
The index.html file contains JavaScript code for initializing and communicating with a stockfish worker. Dependencies: stockfish.js and stockfish.wasm.
server.js
index.html
App.tsx
Attached Screenshot of current output while fetching index.html
Any help would be highly appreciated.