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

Fix create-react-app to work with relative paths #2565

Closed
nhooyr opened this issue Jan 11, 2021 · 4 comments
Closed

Fix create-react-app to work with relative paths #2565

nhooyr opened this issue Jan 11, 2021 · 4 comments
Assignees
Labels
enhancement Some improvement that isn't a feature
Milestone

Comments

@nhooyr
Copy link
Contributor

nhooyr commented Jan 11, 2021

See #2222 and the associated PRs.

Need to fix it to use a relative homepage with webpack-dev-server assets and the /sockjs-node.

@nhooyr nhooyr added the enhancement Some improvement that isn't a feature label Jan 11, 2021
@nhooyr nhooyr added this to the v3.8.1 milestone Jan 11, 2021
@nhooyr nhooyr self-assigned this Jan 11, 2021
@nhooyr
Copy link
Contributor Author

nhooyr commented Feb 4, 2021

See also facebook/create-react-app#8623

nhooyr added a commit to nhooyr/create-react-app that referenced this issue Feb 4, 2021
nhooyr added a commit to nhooyr/create-react-app that referenced this issue Feb 4, 2021
nhooyr added a commit to nhooyr/create-react-app that referenced this issue Feb 4, 2021
As long as client side routing isn't actively used, a relative
$PUBLIC_URL should work correctly in both development and production.
There's no reason it should be limited to production.

Closes facebook#8623

Also see coder/code-server#2565
nhooyr added a commit to nhooyr/create-react-app that referenced this issue Feb 4, 2021
As long as client side routing isn't actively used, a relative
$PUBLIC_URL should work correctly in both development and production.
There's no reason it should be limited to production.

Closes facebook#8623

Also see coder/code-server#2565
@nhooyr
Copy link
Contributor Author

nhooyr commented Feb 4, 2021

Opened facebook/create-react-app#10503

nhooyr added a commit to nhooyr/create-react-app that referenced this issue Feb 5, 2021
As long as client side routing isn't used, a relative $PUBLIC_URL should
work correctly in both development and production.
There's no reason it should be limited to production.

Closes facebook#8623

Also see coder/code-server#2565
@nhooyr
Copy link
Contributor Author

nhooyr commented Feb 5, 2021

So it looks like the reason everyone usually absolute paths is that webpack doesn't support relative urls in its publicPath config for SPAs as it's convention to use a single HTML document for the entire SPA. That way the backend doesn't need to be aware of routing.

Let's say you have a route at /meow/foo that serves some page. Then a relative path like ./bundle.js for that route refers to /meow/bundle.js and not ./bundle.js. But of course you want the latter served. So webpack would need to adjust the relativity of each path in the HTML for each request which isn't something it currently supports.

The other option is to statically render each route but that's beyond CRA.

And you can modify the app's expected absolute public path with $PUBLIC_URL at runtime which isn't too bad so I'll just document that.

nhooyr added a commit to nhooyr/code-server that referenced this issue Feb 5, 2021
Includes updated create-react-app docs.

Closes coder#2565
nhooyr added a commit to nhooyr/code-server that referenced this issue Feb 5, 2021
Includes updated create-react-app docs.

Closes coder#2565
nhooyr added a commit to nhooyr/code-server that referenced this issue Feb 5, 2021
Includes updated create-react-app docs.

Closes coder#2565
@jsjoeio jsjoeio modified the milestones: v3.8.1, v3.8.2 Feb 5, 2021
@jsjoeio jsjoeio closed this as completed Feb 5, 2021
@jsjoeio
Copy link
Contributor

jsjoeio commented Feb 5, 2021

See #2674

@jsjoeio jsjoeio modified the milestones: v3.8.2, v3.8.1 Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Some improvement that isn't a feature
Projects
None yet
Development

No branches or pull requests

2 participants