how to access the homepage /path from within the app?
See original GitHub issueIn the documentation it says to use the ‘homepage’ property in package.json to produce builds that are not mounted at the server root.
How do I access the pathname portion of this property in the application? I need to use it, for instance, inside <Route> declaration:
<Route path={?homepage.path?} .... />
Similarly, when interacting with react-router’s functions, I need to access it. I’d like this to be DRY. Thank you.
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
How is it possible to access homepage from package.json in a ...
create .env file in the root of your project. add REACT_APP_HOME_PAGE='/example-path/' to the .env file.
Read more >app-root-path - npm
Determine an app's root path from anywhere inside the app. ... Start using app-root-path in your project by running `npm i app-root-path`.
Read more >Storing and Searching for Application Files - IBI
APP PATH is a list of subdirectories beneath a common parent directory called the Application Root directory (APPROOT). APP PATH is the default...
Read more >The Art of Routing in Flask - Hackers and Slackers
Flask's "Hello world" example defines a route listening at the root our app and executes a view function called home() : from flask...
Read more >Configure apps - Azure App Service - Microsoft Learn
NET Core developers, setting app settings in App Service are like setting ... Use the path D:\home\site\wwwroot to refer to your app's root...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No thank you.
I don’t have your repo cloned, and submitting a PR for a 1 sentence change means at least 3 min of work for me when it would mean 30s of work for you. Also, I don’t want to sign the facebook contributor agreement, and in general I feel I’m doing enough (without pay) for FB here by helping to debug and improve your product, and, more importantly, by teaching it to students. Or at least trying to, given the constraint that a 30 day old version fails documented functionality 😉
On a technical note, I don’t understand why a project “homepage” is the same as the production build deployment target. You probably shouldn’t be using the “homepage” property for this (?)
You can edit documentation on GitHub.
This project has no CLA as far as I know.
It’s your call, sure. I do appreciate your work. As you can imagine, I also have a ton of other issues to take care of including in React itself, and this project is largely driven by community contributions.
For now, that ship has sailed. We could change it at some point when we introduce our own configuration format but we’ve been avoiding decisions about it for now. I think we may introduce optional streamlined configuration in several months, and then we’ll consider making it more explicit.