Hello.
I'm building an app using Electron+React to manage mods on my headless servers, however, when sending a request (using node-fetch) I'm getting a CORS error.
Is this a bug or is it intended? Seems to be a lot of tools out there using the API, and the same request works perfectly when made in the browser.
Mod Portal API - CORS error in Electron app
Mod Portal API - CORS error in Electron app
Containerize everything! | Automate everything! | Optimize everything!
Re: Mod Portal API - CORS error in Electron app
As far as I'm concerned this is not a bug: we don't want random websites to be able to interact with these APIs from the browser. If you are developing a local application using Electron, I believe there are ways to override CORS.
I am open to arguments to convince me otherwise though :)
I am open to arguments to convince me otherwise though :)
ovo
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Mod Portal API - CORS error in Electron app
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Mod Portal API - CORS error in Electron app
Good to know Pretty new to React and Electron so I’ll definitely look up on how to do that.Sanqui wrote: ↑Wed Apr 21, 2021 9:59 am As far as I'm concerned this is not a bug: we don't want random websites to be able to interact with these APIs from the browser. If you are developing a local application using Electron, I believe there are ways to override CORS.
I am open to arguments to convince me otherwise though
So, no arguments from me
Containerize everything! | Automate everything! | Optimize everything!
Re: Mod Portal API - CORS error in Electron app
use Access-Control-Allow-Origin: *IzaacJ wrote: ↑Wed Apr 21, 2021 4:31 pmGood to know Pretty new to React and Electron so I’ll definitely look up on how to do that.Sanqui wrote: ↑Wed Apr 21, 2021 9:59 am As far as I'm concerned this is not a bug: we don't want random websites to be able to interact with these APIs from the browser. If you are developing a local application using Electron, I believe there are ways to override CORS.
I am open to arguments to convince me otherwise though
So, no arguments from me
another method would be to have a local PHP script that you call, which solely acts as a proxy to the remote API. then CORS is preserved.