Skip to content

Commit 549b8ac

Browse files
sidharthachatterjeeDSchau
authored andcommitted
fix(gatsby): Ensure publicPath is always relative for gatsby develop (#11227)
In `gatsby develop` we were setting `publicPath` for `webpack-dev-server` to an absolute url _constructed_ from the program host, port and protocol This is unnecessary and causes HMR and static links to break when viewed on a separate device over a network like in this screenshot below ![screenshot 2019-01-23 19 04 21](https://user-images.githubusercontent.com/7701981/51617923-3dbc2d80-1f53-11e9-86cf-d4c49ec18f42.png) This pull request fixes this by making the publicPath _always_ relative Fixes #11219 and #5801
1 parent f064c9f commit 549b8ac

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

packages/gatsby/src/utils/webpack.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ module.exports = async (
107107
// Add /* filename */ comments to generated require()s in the output.
108108
pathinfo: true,
109109
// Point sourcemap entries to original disk location (format as URL on Windows)
110-
publicPath:
111-
process.env.GATSBY_WEBPACK_PUBLICPATH ||
112-
`${program.ssl ? `https` : `http`}://${
113-
program.host
114-
}:${webpackPort}/`,
110+
publicPath: process.env.GATSBY_WEBPACK_PUBLICPATH || `/`,
115111
devtoolModuleFilenameTemplate: info =>
116112
path.resolve(info.absoluteResourcePath).replace(/\\/g, `/`),
117113
// Avoid React cross-origin errors

0 commit comments

Comments
 (0)