support PUBLIC_URL during development as well
See original GitHub issueIs this a bug report?
no
Situation
Imagine I want to have the next product structure:
- SPA (created using
create-react-app
), which is going to be served as/auth
- API, which is going to be served as
/auth/api/*
- gateway, which resolves all the requests to the appropriate microservices
Here is a demo repo I prepared.
Problem
In the current version of CRA
the variable PUBLIC_URL
is ignored during the development.
The closest answer to the question why?
which I found was this:
https://github.com/facebook/create-react-app/commit/30ee52cf3b2cbb6ac70999c02b1196bcaba8d4ca#diff-a7f98c18479be87c9f33e7604dbd1a09L33
which was updated by https://github.com/facebook/create-react-app/commit/30ee52cf3b2cbb6ac70999c02b1196bcaba8d4ca#diff-dc0c4e7c623b73660da1809fc60cf6baR74 (@Timer)
But this is exactly what prevents people from developing CRA
applications while being under the gateway. I think it is quite handy in the “microservices” world.
Question
Are there any solutions to this problem? Is this something we can change in the CRA behaviour?
Regards,
Issue Analytics
- State:
- Created 5 years ago
- Reactions:36
- Comments:14 (5 by maintainers)
Following this as I m not able to get parity in my dev and prod environment. I have 2 react apps which I m trying to host from domain.com/path1 and domain.com/path2 For npm run build, PUBLIC_URL is set to /path1 or /path2 and the index.html neatly uses /path1/static. However, the same doesnot happen when we do npm start. How do we get dev/prod parity in this case?
I believe this issue should not be closed. At least it will be good to receive an answer from the
create-react-app
contributors to understand if it’s a feature or bug.@Timer @gaearon