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

Github redirect uri not match. When i use https,how to deal with it? #94

Open
LingBrian opened this issue May 24, 2024 · 7 comments
Open

Comments

@LingBrian
Copy link

This is my configs
image
Oh,it is so awful!
image

@Bryceed
Copy link

Bryceed commented Jun 3, 2024

Same problem using Discord as provider
#81 (comment)

@LingBrian
Copy link
Author

I failed to use it and there are few documents,so I prepare to develop my own oath2 application.😭😭😭😭

@raggesilver
Copy link
Contributor

After thorough investigation (10 minutes playing with it), I found that something is downgrading the https request to http. Adding a log after this line will show us that the request the GitHub handler receives is flagged as http.

// getRequestURL(event) prints out:
{ href: 'http://localhost:3000/auth/github',
  origin: 'http://localhost:3000',
  protocol: 'http:',
  username: '',
  password: '',
  host: 'localhost:3000',
  hostname: 'localhost',
  port: '3000',
  pathname: '/auth/github',
  search: '',
  searchParams: URLSearchParams {},
  hash: '' }

Since this package uses the href returned by getRequestURL, it's pretty obvious why GitHub rejects it.

Any thoughts @Atinux? Is this Vite/Nuxt dev server?

PS: I made sure the navigation from UI to Nuxt Auth Utils' GitHub end-point was https. Tested on both Safari and Firefox on macOS.

Copy link
Owner

Atinux commented Jun 17, 2024

Is your project behind a proxy?

If so, it might be because we don't specify the xForwardedProto option 🤔

https://github.com/unjs/h3/blob/3249ca7ff5a430d59de6f9948478284dce395c97/src/utils/request.ts#L335

@raggesilver
Copy link
Contributor

Is your project behind a proxy?

If so, it might be because we don't specify the xForwardedProto option 🤔

https://github.com/unjs/h3/blob/3249ca7ff5a430d59de6f9948478284dce395c97/src/utils/request.ts#L335

I haven't set up one manually.

This is my whole nuxt.config.ts:

export default defineNuxtConfig({
  devtools: { enabled: true, componentInspector: true },
  devServer: {
    https: true,
  },
  css: ["@unocss/reset/tailwind-compat.css", "~/assets/css/main.css"],
  modules: [
    "shadcn-nuxt",
    "@unocss/nuxt",
    "nuxt-auth-utils",
    "nuxt-icon",
    "@vueuse/nuxt",
    "@hebilicious/vue-query-nuxt",
  ],
  vueQuery: {
    queryClientOptions: {
      defaultOptions: {
        queries: {
          staleTime: 1000 * 60 * 5, // 5 minutes
        },
      },
    },
  },
});

Does devServer: { https: true } set up a proxy?

@LingBrian
Copy link
Author

Is your project behind a proxy?

If so, it might be because we don't specify the xForwardedProto option 🤔

https://github.com/unjs/h3/blob/3249ca7ff5a430d59de6f9948478284dce395c97/src/utils/request.ts#L335

Yes,I set a nginx proxy for this application port and I bind it to my domain dev.brl0.top.

@lmiller1990
Copy link

lmiller1990 commented Jun 26, 2024

Same issue for me -- I am using nignx to forward my port 80 traffic to Nuxt running on port 3000, and I notice the redirect_url is http, which is a mismatch. 🤔

This happens for both github and google, and probably others.

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

No branches or pull requests

5 participants