radical-data / queering-the-map

Queering the Map is a community-based platform where individuals anonymously pin their queer experiences and stories on a global map.
https://queeringthemap.com
16 stars 5 forks source link

Allow preview URLs on Netlify to talk to PMTiles (CORS) #42

Open nielsbom opened 3 months ago

nielsbom commented 3 months ago

Previews of branches are deployed at URLs like: https://deploy-preview-<PR number>--queeringthemap.netlify.app/

To allow sites on those domains to do requests to https://tiles.queeringthemap.com/basemap/* we need to configure the ALLOWED_ORIGINS variable of the Cloudflare Worker serving those requests, this is a CORS issue.

Putting literal domains (including subdomains) in there works, but would then be necessary for each separate PR (kinda ugly). It might be possible to use a wildcard or regex value but I haven't got that working yet.

This Stack Overflow answer may be of help.

jokroese commented 3 months ago

What do you think about tracking and develop the Cloudflare Worker code (worker.js and any settings) within this repo? We could setup a new folder such as cloudflare-workers or pmtiles for this. It would help with working on issues like this as well as make our setup more reproducible for others when this all moves to being a template for other projects.

For keeping them synchronised, there is Wrangler a CLI tool for managing Cloudflare Worker projects.

jokroese commented 4 weeks ago

As this is an issue with the workflow and CI, this could lead to us adding bugs elsewhere without realising it. I'm keen to sort this out soon.

I'll think about it again this week. As @nielsbom points out, CORS doesn't allow dynamic URLs. However, I think we can add it to the code itself.

If anyone has thoughts, please share them!

jokroese commented 4 weeks ago

I also plan on integrating this code into the repository itself as it will make it easier for others to set up community maps.