-
Notifications
You must be signed in to change notification settings - Fork 519
Server rendering with base url #571
Comments
Probably multiple ways of solving this.
|
if i remove the root path, then the initial load will give this error:
also deep link to /myapp/account will throw the same error. one way i might be able to solve this is to include the baseUrl in all routes, e.g.
howerver, i'd prefer to not have to repeat the base url in every route. |
You dont need to include it in every route Instead set Then use relative routes. If you look trough the closed issues you will find discussions on this setup. |
where in boot-server should i set |
I'm thinking the reason renderProps throws is due to absolute route paths. I'm defining my routes as relative/ and not /absolute, and have not seen the problem you describe. Could you try the combination of not starting your routes with a slash + setting basePath in boot-client from window.baseUrl You can create the global from params in your boot-server
Then set basepath if defined
|
if i remove the leading slash from my routes, react-router is not able to find the url, and will error:
i've pushed a simple version of the example project to my repo: in my routes file (https://github.com/peter-dangelo/aspnetspa/blob/master/ClientApp/routes.tsx) i currently have two routes for counter, |
This is now implemented (as in, will work automatically) in the latest templates sources in the repo, and will take effect as of the next release, which will be part of the ASP.NET Core 2.0 release. |
hello - my app is based off the aspnetcore_spa yeoman generator (react with redux variety). i need to host this app under a base url, and am having an issue when reloading a deep link page. in my boot-client file i have this:
and my routes file:
app works fine until i refresh from the /myapp/account url. this results in an error thrown from the boot-server file on this line:
i'm not sure if this is a react-router issue? the odd thing is if i comment out that throw, everything seems to be working fine. if i hit a non-existent route, e.g. /myapp/bad, then react-router issues a warning that the location did not match any routes, and an empty page is returned. not a great UX. but having deep link refreshes is a must-have.
any help or advice would be greatly appreciated!
thanks
The text was updated successfully, but these errors were encountered: