Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch-all page route gives error when using nuxtApp under setup #28335

Closed
gokhantaskan opened this issue Jul 28, 2024 · 2 comments
Closed

Catch-all page route gives error when using nuxtApp under setup #28335

gokhantaskan opened this issue Jul 28, 2024 · 2 comments

Comments

@gokhantaskan
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v20.11.0
  • Nuxt Version: 3.12.4
  • CLI Version: 3.12.0
  • Nitro Version: 2.9.7
  • Package Manager: pnpm@9.5.0
  • Builder: -
  • User Config: compatibilityDate, future, devtools, typescript, imports, runtimeConfig, app, css, modules, vite
  • Runtime Modules: @nuxt/eslint@0.3.13, @nuxt/fonts@0.7.1, @nuxtjs/tailwindcss@6.12.1, @nuxt/icon@1.3.1, @pinia/nuxt@0.5.2
  • Build Modules: -

Reproduction

I cannot follow the exact flow because it requires the use of a local development environment.

https://stackblitz.com/edit/nuxt-starter-9iabft?file=app%2Fpages%2Fauth%2Fconfirm-email%2F%5B...slug%5D.vue

Describe the bug

I have an API endpoint: /auth/confirm-email/{uidb64}/{token}, and I want to follow the same path on the front side.

I created the following page: ~/app/pages/auth/confirm-email/[...slug].vue. Here is the code:

<!-- /auth/confirm-email/{uidb64}/{token} -->
<script setup lang="ts">
import { useNuxtApp } from "#app";
import { ENDPOINTS } from "~~/lib/constants/endpoints";

const route = useRoute();
const [uidb64, token] = route.params.slug as string[];

const { $api } = useNuxtApp();

console.log($api);
// { [AsyncFunction: $fetch2]
//   raw: [AsyncFunction: $fetchRaw2],
//   native: [Function (anonymous)],
//   create: [Function (anonymous)]
// }

await $api(`${ENDPOINTS.Auth.ConfirmEmail}/${uidb64}/${token}`)
  .then(() => {
    navigateTo({ name: "LoginView" });
  })
  .catch(err => {
    throw createError(err);
  });
</script>

<template>
  <div class="tw-text-center">Confirming...</div>
</template>

The URL can be obtained from the confirmation email. When I click the link, I see the following:

image

I can't catch the exact error during the reproduction, but this is the result.

Additional context

No response

Logs

No response

Copy link

stackblitz bot commented Jul 28, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@gokhantaskan
Copy link
Author

I believe it has been resolved using experimental:asyncContext. My bad 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant