Open basham opened 2 years ago
Oh, right. This is something ExtensionServeContent
lets you configure, we should just do that for the other extensions too.
Maybe this should be something you configure on the server, and the server modifies the response's CORS headers before sending it out.
Dealing with the "OPTIONS" request could be added to the extensions/sync_http.ts
code as this will also fix the, unfortunately, still existing CORS issue when running a replica server on Glitch.
See screenshot:
One good way to solve this too is that - if you can - to run your web app within a docker image which uses nginx as proxy web server and then you can do a proxy_pass to the Glitch domain from a "local" folder, like "/api"; You will avoid CORS issues because to the browser the requests will look like it's the same domain.
I'm syncing a local Deno replica server (v3.0.0) with a local browser app (Earthstar v9.3.2), using the
ExtentionSyncHttp
extension. However, when the browser starts to sync, it immediately fails due to CORS.Chrome Dev Tools elaborates on this issue:
I solved this by using a modified version of
ExtentionSyncHttp
. Before getting theresponse
object from the syncer, I added this conditional:There is likely a cleaner way to implement it. I don't know if there are other side cases to consider. But this worked for me.