-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Can gatsby develop
*not* include host and port for images?
#5264
Comments
I'm not sure why (and if) this is needed - but if You would like to try changing it - I think here's place where host is added to paths - gatsby/packages/gatsby/src/utils/webpack.config.js Lines 90 to 92 in fcc5019
|
@pieh Re-capping what I said above, it is needed because for Regarding the solution. I have taken a look at the piece of code you mentioned. It seems to be related to the JS files, while I have issues with image: import pic01 from '../assets/images/pic01.jpg' in Correct me if I'm wrong but changing the line 91 in |
gatsby develop
*not* include host name for assets?gatsby develop
*not* include host and port for images?
For the time being I changed the line that pieh advised above. publicPath: `${program.ssl ? `https` : `http`}://${program.host}:${webpackPort}/`, to publicPath: `/`, It seems to cover all assets including images. |
I have this problem as well. Instead of changing an internal file, a better (but still a workaround I think) solution is adding this piece of code in the exports.modifyWebpackConfig = ({config, stage}) => {
switch(stage) {
case 'develop':
config._config.output.publicPath = `/`;
break;
}
}; |
I think this is solved in v2 by setting an environment variable GATSBY_WEBPACK_PUBLICPATH |
Thanks @dgopsq and @frankf-cgn for the tips. I got it to work by adding this to if (process.env.NODE_ENV === 'development') {
process.env.GATSBY_WEBPACK_PUBLICPATH = '/'
} |
By default (and rather confusingly), Gatsby uses a `publicPath` with fully-qualified domain name when in development, but only relative path when in production. This fixes that, setting both to relative paths. Cf.: gatsbyjs/gatsby#5264
@frankf-cgn That flag is also in V1 afaik. |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub issues, we have to clean some of the old issues as many of them have already been resolved with the latest updates. Please make sure to update to the latest Gatsby version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 |
This issue is being closed because there hasn't been any activity for at least 30 days. Feel free to open a new one if you still experience this problem 👍 |
Thank you all for the solutions. I am just commenting in case anyone else searches for this problem. It is the solution I needed to run |
This is still happening to me when I use |
@kennu this is likely something different with your personal environment setup. Does this issue also persist in something like e.g. create-react-app? |
I realized the project was using an older version of Gatsby, sorry for the trouble. Images are working fine with 2.3.16. If anyone else stumbles here from google because of the 0.0.0.0 issue, make sure you upgrade Gatsby first. |
I have Gatsby 1.1.51 development server running like this in the docker container
I access the site by another IP.
The site is not accessible by
0.0.0.0
from my host.The problem is all the assets that I use
are rendered with hostname in them.
Like this pic01 will get rendered as
http://0.0.0.0:80/static/pic01.b9959e16.jpg
Question:
Can I tell
gatsby develop
to not include that hostname and just use relative paths for all assets i.e./static/pic01.b9959e16.jpg
?The text was updated successfully, but these errors were encountered: