Anyone able to get Electron app working with CORS

I’ve managed to get Android working, but now I’m stuck with Electron.

It looks like the issue is that I’m missing the “Allow Origin Header” in the preflight request. Any ideas on how to correct this error?

PreflightMissingAllowOriginHeader

I finally got it to work. It requires the capacitor-electron://-. I’m not sure why, but I must have not entered it in the correct config.json and it took a few redeploys and restarting of the electron app to have it work successfully.

    "cors": {
        "origin": [
            "http://localhost",
            "http://localhost:62994",
            "capacitor-electron://-"
        ],
1 Like

You might also try this solution:

Then you don’t need CORS at all. Not sure if it works for Electron but you can try

Thanks @George, but I don’t want to disable security.

You are not disabling any security, just cors checks - those are also not performed in your browser if you call the url directly.

All security provider and other restrictions stay in place.

oh wow! Ok.

Solution in Musings on Mobile App Development in Wappler with CORS