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

Default router behaviour issues with client-side callback (hash) #15381

Closed
kai-oswald opened this issue Nov 5, 2022 · 2 comments · Fixed by nuxt/framework#8843
Closed

Default router behaviour issues with client-side callback (hash) #15381

kai-oswald opened this issue Nov 5, 2022 · 2 comments · Fixed by nuxt/framework#8843

Comments

@kai-oswald
Copy link

Environment


  • Operating System: Windows_NT
  • Node Version: v16.13.2
  • Nuxt Version: 3.0.0-rc.13
  • Nitro Version: 0.6.1
  • Package Manager: npm@7.24.0
  • Builder: vite
  • User Config: modules
  • Runtime Modules: @nuxtjs/tailwindcss@6.1.3, @nuxtjs/supabase@0.2.2
  • Build Modules: -

Reproduction

Update to rc.13, add sign in with oauth of supabase.

Describe the bug

Supabase oauth sign in redirects to "/#access_token....". To set the token.
Default router options find the hash and try to navigate causing the error.

As a default router option, there should be a check to verify that the hash exists so this error will be prevented.

Additional context

Overwriting the default scroll behaviour with app/router.options fixes the error.

import type { RouterConfig } from "@nuxt/schema";
// https://router.vuejs.org/api/interfaces/routeroptions.html
export default {
scrollBehavior(to, from) {

}
};

Logs

DOMException: Failed to execute 'querySelector' on 'Document': '#access_token=ey...' is not a valid selector.
Copy link
Member

Reproduction: https://stackblitz.com/edit/github-lqatun

@FernandoArteaga
Copy link

I'm facing the same issue, with rc.12 getting the hash worked correctly. After upgrading to rc.13 it still works but shows a console error:

Uncaught (in promise) DOMException: Failed to execute 'querySelector' on 'Document': '#access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...........more token........
is not a valid selector.
    at _getHashElementScrollMarginTop (http://localhost:3000/_nuxt/node_modules/.pnpm/nuxt@3.0.0-rc.13_ei2llrrr25ag5uzky3pllqjd4q/node_modules/nuxt/dist/pages/runtime/router.options.mjs?v=7cfeb9ef:32:25)
    at scrollBehavior (http://localhost:3000/_nuxt/node_modules/.pnpm/nuxt@3.0.0-rc.13_ei2llrrr25ag5uzky3pllqjd4q/node_modules/nuxt/dist/pages/runtime/router.options.mjs?v=7cfeb9ef:15:36)
    at http://localhost:3000/_nuxt/node_modules/.vite/deps/vue-router.js?v=7cfeb9ef:2362:34
_getHashElementScrollMarginTop  @  router.options.mjs?v=7cfeb9ef:32
  scrollBehavior  @  router.options.mjs?v=7cfeb9ef:15
  (anonymous)  @  vue-router.mjs:3485

@danielroe danielroe self-assigned this Nov 9, 2022
danielroe referenced this issue in nuxt/framework Nov 9, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants