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

Public files not served from subdirectory in development #5262

Closed
adueck opened this issue Oct 3, 2018 · 2 comments
Closed

Public files not served from subdirectory in development #5262

adueck opened this issue Oct 3, 2018 · 2 comments

Comments

@adueck
Copy link

adueck commented Oct 3, 2018

I am developing an app which I am deploying from a subdirectory.

In my package.json I have included "homepage": "https://example.com/my-subdirectory" and everything works great for deployment.

The only problem is when developing, my public folder assets get served from http://localhost:3000/ and not http://localhost:3000/my-subdirectory/.

Because I am using react-router and also doing some fetching and reading from resources in the public directory I do need to use the sub-directory in the urls, and so I need to modify some of my code while developing, and then again when deploying.

It would be wonderful if the public assets could be served from http://localhost:3000/subdirectory/ when there is "homepage": "https://example.com/subdirectory" in package.json.

@Timer
Copy link
Contributor

Timer commented Oct 3, 2018

We're adding this in the future, for now you can prefix your assets with process.env.PUBLIC_URL, e.g. <img src={process.env.PUBLIC_URL + '/my-thing.jpg'} />.

@Timer
Copy link
Contributor

Timer commented Oct 3, 2018

Merging into #4158

@Timer Timer closed this as completed Oct 3, 2018
@lock lock bot locked and limited conversation to collaborators Jan 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants