question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support PUBLIC_URL during development as well

See original GitHub issue

Is this a bug report?

no

Situation

Imagine I want to have the next product structure:

  1. SPA (created using create-react-app), which is going to be served as /auth
  2. API, which is going to be served as /auth/api/*
  3. 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:closed
  • Created 5 years ago
  • Reactions:36
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
prem911commented, Apr 6, 2019

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?

5reactions
PavelPolyakovcommented, Mar 18, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure the create-react-app public URL post-build with ...
For a project, I had the requirement of making the public URL of the application configurable via an environment variable that can be...
Read more >
How to configure service workers with create-react-app
To begin the development, run `npm start`. To create a production bundle, use `npm run build`. --> <script> if ('serviceWorker' in ...
Read more >
Announcing AWS Lambda Function URLs: Built-in HTTPS ...
Function URLs are natively supported by the Lambda API, and you can start using it via the AWS Management Console or AWS SDKs,...
Read more >
Connect to MongoDB from App Service on public url
I can connect fine from local development desktop. I have whitelisted all Azure App Service Outbound IP addresses and even whitelisted 0.0.0.0/0 and...
Read more >
How To Set Up a React Project with Create React App
It's supported by Facebook and does many of the same things as npm . ... but now these are implemented in npm as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found