-
Notifications
You must be signed in to change notification settings - Fork 489
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
Cross-Origin Request Blocked when using custom host = "0.0.0.0" #134
Comments
Also to add the following observation:
So the specification intends for port and host to default to these values, but the actual source line
shows that default host is localhost and not 0.0.0.0 This appears to be the default host is actually localhost. Perhaps that is why |
Upon changing the gridsome.config.js file and set host = 192.168.1.1 the rest of code works. So the simple solution, to be added clearly into the documentation, is to put the actual IP into the gridsome.config.js and not to use "0.0.0.0". This means a source repo may have a fixed IP in the config. The more complex solution, is to separate the host of the client and server into two constants:
I hope my analysis is correct, since I have only one day experience with Gridsome so I really don't know too much about it, but conceptually it is very similar to Nuxtent and that also uses a separate content server bundled into the build process. |
Hi @kaceo I've also been having problems with a similar set up, complicated by trying to gridsome in docker containers on a different machine from my browser. See #58 for some more information. In my case I can't seem to get it working unless I hack a file to specify a particular IP/domain for the GRAPHQL_ENDPOINT |
Yes I imagine the use of docker container would complicate the situation because the client and server are on different hosts and both CORS and firewall may stop direct access without throwing meaningful error. The basic starter template should be able to run without additional IP configuration on a client != server IP situation -- but it doesn't currently. This means anyone trying Gridsome for the first time may give up when even the starter template could not run correctly. |
It worth mentioning you can also get it working by setting the host to This can be achieved by adding a
This way it won't be necessary to manually enter the IP every time. |
We are improving this in the next release :) #58 (comment) |
Description
When a custom host is used in gridsome.config.js, the client cannot connect to the graphql layer
Steps to reproduce
Clone gridsome/gridsome-starter-markdown-blog on test machine (IP = 192.168.1.1)
yarn upgrade
edit gridsome.config.js to include "host: 0.0.0.0"
yarn develop
Compiled successfully in 7199ms
Site running at: http://0.0.0.0:8080/
Explore GraphQL data at: http://0.0.0.0:8080/___explore
From second workstation, use browser to access 192.168.1.1
Expected result
Home page of the test blog
Actual result
Empty screen.
Console log shows:
The text was updated successfully, but these errors were encountered: