Skip to content
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

change CRA "PUBLIC_URL" post build process #6

Closed
kkarkos opened this issue Aug 23, 2018 · 1 comment
Closed

change CRA "PUBLIC_URL" post build process #6

kkarkos opened this issue Aug 23, 2018 · 1 comment

Comments

@kkarkos
Copy link

kkarkos commented Aug 23, 2018

Hi,

your comment on facebook/create-react-app#2353 brought me here. I'm facing the problem that a client wants to serve ONE CRA build on different static server without using pipelines etc.. So the "PUBLIC_URL" would need to change post build based on a config file so the files can be server from the correct "static" folder.

You are writing

When serving the files, I also implemented some best-match redirects to allow the app base url (PUBLIC_URL) to be configured at runtime as well.

Could you please point me in the right direction? I can't find anything about "best-match redirects" in the docs.

Cheers

@pscanf
Copy link
Member

pscanf commented Sep 7, 2018

Hey @kkarkos , sorry for the late reply, I saw the issue while on vacation and then forgot about it.

The comment you quoted was a bit inaccurate on my part, and so maybe a bit misleading. app-server does not dynamically change your app's PUBLIC_URL, rather, it serves the correct content even when you set PUBLIC_URL (at build time) to ., making all links relative. The outcome though is basically the same: at runtime you can change the base url of the app without having to rebuild it (though you might have to change app-server's config option --basePath, but that's a runtime configuration). Here you can find a bit of documentation explaining how requests are routed so that the correct content is served.

I actually forgot to add this info to the doc on how to use app-server with CRA, I will put it in now.

Thanks for reporting, let me know if you still have issues

@pscanf pscanf closed this as completed Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants