Infinite redirect in middleware
export default defineNuxtRouteMiddleware(async (to, from) => {
const url = window.location.href;
// Check if we are on "localhost:3000"
if (url.includes("localhost:3000")) {
console.log(to.path, from.path);
return navigateTo(to.fullPath);
}
return abortNavigation();
});
How can i solved this ?
3 Replies
@manniL / TheAlexLichter please help
what are you trying?
(also make sure that window is actually a thing, it isn't on server)
how can i get full url in middleware ?
export default defineNuxtRouteMiddleware(async (to, from) => {
const url = useRequestURL();
if (!url.href.includes("localhost:3000") && !url.href.includes("ejily.com")) {
// return abortNavigation();
return navigateTo("/");
}
});
this is working now.