Server rendering with base url #1126

Closed
opened 2025-08-09 17:18:58 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @peter-dangelo on 1/9/2017

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:

const browserHistory = useRouterHistory(createHistory)({
    basename: '/myapp'
});

const history = syncHistoryWithStore(browserHistory, store);

and my routes file:

<Route path='/myapp' component={Layout} >
    <Route path="/" components={{body:AccountsPage}} />
    <Route path="/account" components={{body:ManageAccountPage}} />
</Route>

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:

if (!renderProps) {
    throw new Error(`The location '${ params.url }' doesn't match any route configured in react-router.`);
}

// output: The location '/myapp/account' doesn't match any route configured in react-router.

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

*Originally created by @peter-dangelo on 1/9/2017* 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: const browserHistory = useRouterHistory(createHistory)({ basename: '/myapp' }); const history = syncHistoryWithStore(browserHistory, store); and my routes file: <Route path='/myapp' component={Layout} > <Route path="/" components={{body:AccountsPage}} /> <Route path="/account" components={{body:ManageAccountPage}} /> </Route> 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: if (!renderProps) { throw new Error(`The location '${ params.url }' doesn't match any route configured in react-router.`); } // output: The location '/myapp/account' doesn't match any route configured in react-router. 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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1126
No description provided.