`basename` issues
See original GitHub issueI can’t seem to get the basename
property on navigation
to work. I assume it serves the exact same purpose as react router’s basename.
Redirects and links seem to ignore it. Here is my main <App />
component:
function App() {
const dispatch = useDispatch();
const { profile } = useReduxState('user');
const { fieldTypes } = useReduxState('app');
useEffect(() => {
dispatch(gapiInit());
}, [dispatch]);
return (
<Router
routes={routes}
basename={BASEPATH}
context={{ profile, fieldTypes }}
>
<MainLayout>
<Suspense fallback={null}>
<View />
</Suspense>
</MainLayout>
<Message />
<ConfirmationDialogue />
</Router>
);
}
My main routes
file
const routes = mount({
'*': map((request, context) =>
!context.profile || !context.fieldTypes
? redirect(
'/login?redirectTo=' +
encodeURIComponent(request.originalUrl),
{ exact: false }
)
: map(() => {
store.dispatch(setConfirmRouteChange(false));
store.dispatch(setConfirmationDialogue(null));
return pageRoutes;
})
),
// Catches the root URL before login to avoid adding 'redirectTo' by default
'/': map((request, context) =>
!context.profile || !context.fieldTypes
? redirect('/login')
: pageRoutes
),
'/login': map(async (request, context) =>
!context.profile || !context.fieldTypes
? route({
title: 'Login',
view: <LoginPage />
})
: redirect(
request.params.redirectTo
? decodeURIComponent(request.params.redirectTo)
: '/'
)
)
});
BASEPATH is set to /dist/
. Navigating to localhost:8080/dist
redirects me to localhost:8080/login
.
Any help would be greatly appreciated 🙏
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
c++11 - Issue with basename - Stack Overflow
So I am having an issue using basename for one of my programming assignments for school. I have tried getting a simplier version...
Read more >basename problem - The UNIX and Linux Forums
Basename in subshell ... Hi All, I would like to improve my bash scripting skill and found a problem which I do not...
Read more >Problems with basename in a loop - Unix Stack Exchange
This means your for loop is running with a single entry, and passing that file * to basename. Then, out=$(basename $arqin) is expanding...
Read more >Problems with basename · Issue #5000 · remix-run/react-router
Hi guys, Congrats for the v4 release! I've problems using basename. The basename is prepended or removed depending on the use case.
Read more >basename - The Open Group Publications Catalog
basename - return non-directory portion of a pathname. SYNOPSIS. basename string [suffix] ... Issue 6. IEEE PASC Interpretation 1003.2 #164 is applied.
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
The
basename
option is a little different in Navi to react-router – it does affect routing, but doesn’t effect links/redirects. This allowsbasename
to be used to integrate Navi with react-router and other routers, but also means that you’ll need to pass the full path for links/redirects.One way to do this would be to add basename to the routing context and add it into redirects manually.
Not in our case I’m afraid. We have dozens of components and, with a minor exception, they’re all written with the router-agnostic thought in mind. To give them Navi context woud mean editing all of them and making them more navi-dependent either by calling
useCurrentRoute()
from inside of the components or by wrapping all the components into a customwithRouter()
hoc to get the context basename passed inprops
.