Nuxt, router.push("/api/login") raises 404 error
router.push("/api/login") redirect /api/login but it raises 404 error, however when I refresh the page it works, what should I use instead of router.push ?
5 Replies
Error: Page not found: /api/login at createError (http://localhost:3000/_nuxt/node_modules/h3/dist/index.mjs?v=e5c10816:79:15) at http://localhost:3000/_nuxt/node_modules/nuxt/dist/pages/runtime/plugins/router.js?t=1711971066506&v=e5c10816:174:54 at fn (http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.js?v=e5c10816:182:44) at Object.runWithContext (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-3K6LZAJX.js?v=e5c10816:4893:18) at callWithNuxt (http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.js?v=e5c10816:187:24) at http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.js?v=e5c10816:32:54 at EffectScope.run (http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-3K6LZAJX.js?v=e5c10816:1313:20) at Object.runWithContext (http://localhost:3000/_nuxt/node_modules/nuxt/dist/app/nuxt.js?v=e5c10816:32:44) at http://localhost:3000/_nuxt/node_modules/nuxt/dist/pages/runtime/plugins/router.js?t=1711971066506&v=e5c10816:174:23
Hey!
Curious: can you try
window.location.href
instead of the router push?
I'm assuming all of this is client side as well?@Egemen Did it work?
navigateTo('/api/logout', {
external: true
});
@Niza , @VKinde , it works.Thank you!