Rookie in coding, needing some help troubleshooting some errors in deployment
Answered
Yacare Caiman posted this in #help-forum
Yacare CaimanOP
# EU TIMEZONE
## Vercel Error from last deployment:
Because i've never learned any coding language deeply and in my opinion website builders often look or work like shit i just tried going for it myself. So i used v0 claude and other Ai's and my general knowledge to pretty much (as far as I know haha) get both front/back-end set up for my website. It it theory just consts of the site to buy the subscription and an admin dashboard for handling them# Website:
-# (I prob could use some help explaining or adding smth further but thats just theory if someone would be so kind)
I just need to get the ability of selling some links as a subscription (got pretty much the whole code done.# My attempts for troubleshoot
I used vercel as my deployment platform, connected it with my GitHub repository and stripe for payment. Google for authentication and E-Mail login.
Because of my limited in depth knowledge about my project I mainly tried understanding/finding errors and trying to troubleshoot them with Ai's or docs
## Vercel Error from last deployment:
Failed to compile.
src/app/api/auth/[...nextauth]/route.ts
Type error: Route "src/app/api/auth/[...nextauth]/route.ts" does not match the required types of a Next.js Route.
"authOptions" is not a valid Route export field.
Next.js build worker exited with code: 1 and signal: null
Failed to compile.
src/app/api/auth/[...nextauth]/route.ts
Type error: Route "src/app/api/auth/[...nextauth]/route.ts" does not match the required types of a Next.js Route.
"authOptions" is not a valid Route export field.
Next.js build worker exited with code: 1 and signal: null
sh: line 1: >: command not found
Error: Command "`npm run build` or `next build`" exited with 127
Answered by LuisLl
Do not export the
Only allowed HTTP methods handlers are allowed to be exported from API Routes. So, only export functions with name
authOptions
object from inside the route.ts
file. Only allowed HTTP methods handlers are allowed to be exported from API Routes. So, only export functions with name
GET, POST, PUT, DELETE
, etc. that will directly map to a HTTP method.11 Replies
Yacare CaimanOP
## *The exact layout of my code if helpful
How does your
src/app/api/auth/[...nextauth]/route.ts
look like?@LuisLl How does your `src/app/api/auth/[...nextauth]/route.ts` look like?
Yacare CaimanOP
src/app/api/auth/[...nextauth]/route.ts
import NextAuth from "next-auth"
import { PrismaAdapter } from "@auth/prisma-adapter"
import GoogleProvider from "next-auth/providers/google"
import EmailProvider from "next-auth/providers/email"
import prisma from "@/lib/db"
export const authOptions = {
adapter: PrismaAdapter(prisma),
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
}),
EmailProvider({
server: {
host: process.env.EMAIL_SERVER_HOST,
port: process.env.EMAIL_SERVER_PORT,
auth: {
user: process.env.EMAIL_SERVER_USER,
pass: process.env.EMAIL_SERVER_PASSWORD,
},
},
from: process.env.EMAIL_FROM,
}),
],
callbacks: {
async session({ session, user }) {
if (session.user) {
session.user.id = user.id
}
return session
},
},
pages: {
signIn: "/auth/signin",
signOut: "/auth/signout",
error: "/auth/error",
verifyRequest: "/auth/verify-request",
},
}
const handler = NextAuth(authOptions)
export { handler as GET, handler as POST }
Do not export the
Only allowed HTTP methods handlers are allowed to be exported from API Routes. So, only export functions with name
authOptions
object from inside the route.ts
file. Only allowed HTTP methods handlers are allowed to be exported from API Routes. So, only export functions with name
GET, POST, PUT, DELETE
, etc. that will directly map to a HTTP method.Answer
Glad to hear! Please mark the solution:)
@LuisLl Glad to hear! Please mark the solution:)
Yacare CaimanOP
tbh i still got some things not working on wich you or others probably could help me
If the original issue was solved mark the solution and open a new tread, we can happily help
Posting different issues in the same thread goes against the rules, or the intention of the channel
Yacare CaimanOP
yy ok
You can open as many threads as you want, it’s no problem 👍