Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork27.2k
feat(react-scripts): allow PUBLIC_URL in develoment mode#7259
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ArnaudBarre left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
packages/react-scripts/config/webpack.config.js L. 561-563 to update
unrevised6419 commentedJun 26, 2019
@ArnaudBarre done! |
mrmckeb left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@iansu or@ianschmitz - can I get your thoughts on this one?
Uh oh!
There was an error while loading.Please reload this page.
jtblanche left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this fixes the issue I mentioned at#6280 (comment) 👍
64BitAsura commentedJul 13, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@iansu@Timer@gaearon@amyrlam@ianschmitz@petetnt@bugzpodder please review this PR, if all good merge it ASAP and make release please 🙏 , my projects requires and also I don't want to eject since we don't have enough resource to setup packer env 😢 |
mrmckeb commentedJul 15, 2019
@sambathl I'm chasing a second review on this, and then we can merge it in. |
heyimalex commentedJul 15, 2019
I don't think it works when |
heyimalex commentedJul 15, 2019
Ithink all that needs to change is webpackDevServer.config.js needs to check for the relative path when setting publicPath. publicPath:paths.servedPath==="./" ?"/" :paths.servedPath.slice(0,-1) |
unrevised6419 commentedJul 15, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There is also a problem when setting homepage Edit: In this case dev server just served clear |
heyimalex commentedJul 15, 2019
@iamandrewluca Hm, I'm actually not getting that anymore with my changes, so maybe the PUBLIC_URL thing was fixed by ad7e29b? But the dev server is definitely serving index.html when requests for |
raix commentedJan 13, 2020
@iamandrewluca not sure if merging in master will fix the build issue / or at least rerun the build? |
unrevised6419 commentedJan 13, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@raix made a rebase to trigger the build. It seems there is a babel plugin dependency error comming from master. |
lucasmogari commentedJan 14, 2020
I'm trying this branch. I'm curious about why the public url have to end with a slash? If I set the public_url with for example: "PUBLIC_URL=/test" and browsehttp://localhost:3000/test, it redirects the url to:http://localhost:3000/test/test Btw, thanks for this PR, it's very useful. |
unrevised6419 commentedJan 14, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It should not, I'll check. |
lucasmogari commentedJan 15, 2020
Another thing I noticed is that when reloadinghttp://localhost:3000/test/some-path, it returns a 404 error. Reloadinghttp://localhost:3000 works. I don't know if it's related, but I'm running the apps behind a reverse proxy (nginx). |
unrevised6419 commentedJan 15, 2020
@lucasmogari on |
raix commentedJan 15, 2020
@lucasmogari shouldn't it be: |
lucasmogari commentedJan 15, 2020
It actually works both ways. According to nginx docs: https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
The refresh problem happens in both ways too. I think there's something related to what is described in the docs, but there's no guide for nginx. https://create-react-app.dev/docs/deployment/#serving-apps-with-client-side-routing |
lucasmogari commentedJan 15, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yes. What I'm trying to do: http://localhost:3000 proxies tohttp://localhost:3010/ (main app) In dev, refreshinghttp://localhost:3000/some-path works, buthttp://localhost:3000/test/some-path returns 404. |
lucasmogari commentedJan 15, 2020
I found that adding the option (index: paths.publicUrlOrPath) to webpackDevServer.config.js fixed the problem with refreshing: |
raix commentedJan 21, 2020
Just a kind reminder - in 5 days / the 26th of January the original pr for this pull-request turns 1 year. Not often pull-requests live this long so I'm not sure if I should bring cake or flowers? :) (Disclaimer: I'm not trying to push or rush things - even if we desperately want this to be merged) |
unrevised6419 commentedJan 21, 2020
@raix 😄 will live till will be merged 🌹 🌷 💮 |
andriijas commentedJan 31, 2020
@iamandrewluca Can you rebase locally and push? |
unrevised6419 commentedJan 31, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@lucasmogari I addressed the issues you encoutnered, can you try again with the proxy?
@andriijas done! |
unrevised6419 commentedJan 31, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
PR Blocked by a |
andriijas commentedJan 31, 2020
@iamandrewluca In case we forget, ping when |
unrevised6419 commentedJan 31, 2020
Ok, I'll ping. Contacted a webpack maintaner for an ETA. |
lucasmogari commentedJan 31, 2020
With PUBLIC_URL=/test With PUBLIC_URL=/test/ Maybe it's some configuration here. I'm sorry, but I don't have too much time to debug right now. Thanks again! |
unrevised6419 commentedJan 31, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@lucasmogari Try in incognito mode. Or clear all data for If I open |
Co-authored-by: Eric Clemmons <eric@smarterspam.com>Co-authored-by: Alex Guerra <alex@heyimalex.com>Co-authored-by: Kelly <kelly.milligan@gmail.com>
unrevised6419 commentedFeb 2, 2020
@andriijas all done! Need review. |
andriijas commentedFeb 2, 2020
Thanks for your patience everyone, specially @iamandrewluca If anyone wants to do additional testing on their projects - please do! |
kelly-tock commentedFeb 2, 2020
Well done! |
unrevised6419 commentedFeb 2, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I encountered some problems when using proxy with this feature. Investigating. Think I should reorder in a right way proxy middlewares. Also one case Do we revert the PR, and create a new one with fixed problems, or we fix the problem till the next release? |
unrevised6419 commentedFeb 3, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Found the issue. Will make a PR soon. Internal proxy that decides to proxy or not, does not know about public path |
Uh oh!
There was an error while loading.Please reload this page.
Allow
PUBLIC_URLin development modereact-dev-utils/getPublicUrlOrPath)redirectServedPathMiddlewareandgetPublicUrlOrPathDefinitelyTyped/DefinitelyTyped#40982Public API
react-dev-utils/redirectServedPathMiddleware)contentBasePublicPathoption webpack/webpack-dev-server#2150)/Private API
paths.publicUrlandpaths.servedPathintopaths.publicUrlOrPathreact-dev-utils/getPublicUrlOrPath(no side effects)evalSourceMapMiddlewareanderrorOverlayMiddlewarefirst in the middleware chain, redirect does not affect them.PUBLIC_URLnoopServiceWorkerMiddlewareto serve fromservedPathwebpack-dev-server@3.9.0towebpack-dev-server@3.10.0Blocked bywebpack/webpack-dev-server/pull/2150Blocked bywebpack/webpack-dev-server/pull/2374Blocked byhttps://github.com/webpack/webpack-dev-server new patch releaseCloses#6280
Closes#6135
Closes#4158