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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextjs (app router) error: This action with HTTP POST is not supported by NextAuth.js #7482

Closed
lIMonkieIl opened this issue May 8, 2023 · 3 comments
Labels
question Ask how to do something or how something works

Comments

@lIMonkieIl
Copy link

lIMonkieIl commented May 8, 2023

Question 馃挰

I get the below error in the browser can anyone help please
Error: This action with HTTP POST is not supported by NextAuth.js

I get no other errors, I have also included my package.json file so you can see what version Im using and the packages.

on discord i have set up Redirects to : http://localhost:3000/api/auth/callback

How to reproduce 鈽曪笍

the way I have it set up is:

src/app/api/auth/[...nextauth]/route.ts

import NextAuth from "next-auth"
import DiscordProvider from "next-auth/providers/discord"
const handler = NextAuth({
   providers: [
      DiscordProvider({
         clientId: "id",
         clientSecret: "secret",
         authorization: {
            params: {
               scope: "identify email guilds"
            }
         }
      })
   ]
})
export { handler as GET, handler as POST }
.env
NEXTAUTH_SECRET= "123456789",
NEXTAUTH_URL = "http://localhost:3000"
src/app/components/AuthProvider.ts

"use client"
import { SessionProvider } from "next-auth/react"
export default function AuthProvider({ children }: { children: React.ReactNode }) {
   return <SessionProvider>{children}</SessionProvider>
}
src/app/layout.ts

import "./styles/globals.css"
import { Sedgwick_Ave } from "next/font/google"
import AuthProvider from "./components/AuthProvider"
const inter = Sedgwick_Ave({ weight: "400", subsets: ["latin"] })

export default function RootLayout({ children }: { children: React.ReactNode }) {
   return (
      <html className='h-full' lang='en'>
         <body className={`${inter.className} text-white h-full`}>
            <AuthProvider>{children}</AuthProvider>
         </body>
      </html>
   )
}
{
   "name": "community",
   "version": "0.1.0",
   "private": true,
   "scripts": {
      "dev": "next dev",
      "build": "next build",
      "start": "next start",
      "lint": "next lint"
   },
   "dependencies": {
      "@headlessui/react": "^1.7.14",
      "@heroicons/react": "^2.0.17",
      "@reduxjs/toolkit": "^1.9.5",
      "@types/node": "20.0.0",
      "@types/react": "18.2.5",
      "@types/react-dom": "18.2.3",
      "autoprefixer": "10.4.14",
      "eslint": "8.39.0",
      "eslint-config-next": "13.4.0",
      "next": "13.4.0",
      "next-auth": "4.22.0",
      "postcss": "8.4.23",
      "react": "18.2.0",
      "react-dom": "18.2.0",
      "react-icons": "^4.8.0",
      "react-redux": "^8.0.5",
      "react-use": "^17.4.0",
      "tailwindcss": "3.3.2",
      "typescript": "5.0.4",
      "use-between": "^1.3.5",
      "use-immer": "^0.9.0"
   }
}

Contributing 馃檶馃徑

Yes, I am willing to help answer this question in a PR

@lIMonkieIl lIMonkieIl added the question Ask how to do something or how something works label May 8, 2023
@balazsorban44
Copy link
Member

on discord i have set up Redirects to : http://localhost:3000/api/auth/callback

Needs to be http://localhost:3000/api/auth/callback/discord

@lIMonkieIl
Copy link
Author

thank you but i know have another issue,
i have deployed to vercel and the callbackUrl gets set to localhost

so i read my vercel logs:
[next-auth][warn][NEXTAUTH_URL]
https://next-auth.js.org/warnings#nextauth_url

but it still dont work if i have a "NEXTAUTH_URL" set or not so i am a little comfused

@ashishagarwal2023
Copy link

thank you but i know have another issue, i have deployed to vercel and the callbackUrl gets set to localhost

so i read my vercel logs: [next-auth][warn][NEXTAUTH_URL] https://next-auth.js.org/warnings#nextauth_url

but it still dont work if i have a "NEXTAUTH_URL" set or not so i am a little comfused

set the NEXTAUTH_URL On your vercel to the vercel's deploy

i think maybe not setting it is finebecause I think it gets vercel automaicallyy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Ask how to do something or how something works
Projects
None yet
Development

No branches or pull requests

3 participants