Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty making a fetch request in the renderer process to third party API #52

Open
polarathene opened this issue Jan 26, 2019 · 1 comment

Comments

@polarathene
Copy link

polarathene commented Jan 26, 2019

I was previously using electron-react-boilerplate and have raised an issue there about this topic.

I migrated my project and everything is working fine apart from when I make a fetch request to Google, the URL request is handled by a third-party npm package intended for node only due to CORS in the browser. My code worked fine regardless though with their project despite calling from the renderer process.

I had tried disabling the web security when creating the BrowserWindow() in main process, but while it avoided the CORS issue, my request was still unsucessful. I only noticed the request headers having two additional fields, referer which pointed to the localhost dev server, and cookies.

Is there advice on how to get my Electron app to behave more like the linked boiler plate project is doing? I wasn't able to see what they're doing differently(they have special configuration for the webpack dev server, but nothing for production webpack config). In both cases their index.html is loaded via file://filepath rather than http://localhost:port, is it likely to be due to this?

@polarathene
Copy link
Author

Problem is only during dev, when running AppImage (built via docker image), the built version works correctly without error.

That's not practical to develop with though. Is there a way to get this behaviour with yarn dev as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant