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

Application error: a server-side exception has occurred (see the server logs for more information). #3775

Open
5 tasks done
Syammed2429 opened this issue Oct 27, 2023 · 60 comments

Comments

@Syammed2429
Copy link

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

App Id

I'll ask my backend team and update it

AWS Region

ap-southeast-1

Amplify Hosting feature

Backend builds, Deployments, Frontend builds

Frontend framework

Next.js

Next.js version

13.5.3

Next.js router

App Router

Describe the bug

I have a next js app with next auth and it got deployed on aws amplify, and it's not working when it got deployed on aws amplify the app is really breaking and not even working and it's working on local.

It's nextjs app with the app router with next auth and backend with the graphql and deployed on AWS amplify

Application error: a server-side exception has occurred (see the server logs for more information).
Digest: 4286476458
49-f394e00ab3312384.js:1 Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included in this error instance which may provide additional details about the nature of the error.

I'm getting the above errors

Here's my setup

next.config.js

/** @type {import('next').NextConfig} */
const config = {
	webpack(config) {
		config.resolve.fallback = {
			...config.resolve.fallback,
			fs: false,
		};

		return config;
	},
	images: {
		remotePatterns: [
			{
				hostname: "*",
			},
		],
	},
	env: {
		RECAPTCHA_SECRET_KEY: process.env.NEXT_PUBLIC_RECAPTCHA_SECRET_KEY,
		RECAPTCHA_SITE_KEY: process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY,
		NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET
	},
	experimental: {
		serverActions: true,
		typedRoutes: false,
	},
	// FIXME !!TEMPORARY FIX!! because checkout directory has many errors
	typescript: {
		ignoreBuildErrors: true,
	},
	eslint: {
		ignoreDuringBuilds: true,
	},

};

export default config;

auth.ts

import axios from "axios";
import { type NextAuthOptions } from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
// import { type Amplify } from "aws-amplify";
// import awsExports from "@aws-amplify/ui-react";

import { API_URL } from "@/lib/gql";
import { UserLoginDocument, type UserLoginMutation } from "@/gql/graphql";

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
// Amplify.configure({ ...awsExports, ssr: true });

export const authOptions: NextAuthOptions = {
	secret: process.env.NEXTAUTH_SECRET as string,
	session: {
		strategy: "jwt",
		maxAge: 24 * 60 * 60,
	},
	pages: {
		signIn: "/en/login",
	},
	providers: [
		// GoogleProvider({

		// }),
		// eslint-disable-next-line @typescript-eslint/no-unsafe-call
		CredentialsProvider({
			id: "credentials",
			name: "Credentials",
			credentials: {
				email: { type: "email", label: "Email" },
				password: { type: "password", label: "Password" },
				remember: { type: "bool", label: "Remember me" },
			},
			authorize: async (credentials: { email: string; password: string } | undefined) => {
				const { email, password } = credentials || {};

				const res = await axios.post<{ data: UserLoginMutation }>(API_URL, {
					query: UserLoginDocument,
					variables: { email, password },
				});

				if (res.status !== 200) {
					return null;
				}

				if (res.data?.data.userLogin?.token) {
					return {
						id: email || "",
						email,
						...(res.data?.data.userLogin || {}),
					};
				} else {
					return null;
				}
			},
		}),
	],
	callbacks: {
		jwt: async ({ account, token }) => {
			if (account) {
				// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
				token.accessToken = account.access_token;
			}
			// eslint-disable-next-line @typescript-eslint/no-unsafe-return
			return token;
		},
	},
};

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

/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import NextAuth from "next-auth";
import { authOptions } from "@/lib/auth";

// eslint-disable-next-line @typescript-eslint/no-unsafe-call
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };

amplify.yml in the root folder

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm install -g pnpm
        - pnpm install --frozen-lockfile
    build:
      commands:
        - touch .env
        - echo "NEXTAUTH_SECRET=$NEXTAUTH_SECRET" >> .env
        - echo "NEXTAUTH_URL=$NEXTAUTH_URL" >> .env
        - pnpm run i18n && next build
  artifacts:
    baseDirectory: .next
    files:
      - "**/*"
  cache:
    paths:
      - node_modules/**/*

Expected behavior

It should working without any errorsbe working

Reproduction steps

  1. Add the nextauth on nextjs app and deploy on the aws amplify and then it'll will be produce

Build Settings

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm install -g pnpm
        - pnpm install --frozen-lockfile
    build:
      commands:
        - touch .env
        - echo "NEXTAUTH_SECRET=$NEXTAUTH_SECRET" >> .env
        - echo "NEXTAUTH_URL=$NEXTAUTH_URL" >> .env
        - pnpm run i18n && next build
  artifacts:
    baseDirectory: .next
    files:
      - "**/*"
  cache:
    paths:
      - node_modules/**/*

Log output

# Put your logs below this line

Application error: a server-side exception has occurred (see the server logs for more information).
Digest: 4286476458



49-f394e00ab3312384.js:1 Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.

Additional information

No response

@Syammed2429
Copy link
Author

@Jay2113 any help please

@Icegreeen
Copy link

Icegreeen commented Feb 17, 2024

@Syammed2429

Your problem may be in the environment variables.

I had the same problem:

Application error: a server-side exception has occurred (see the server logs for more information). Digest: 4286476458

I solved it by changing the name of the environment variable AUTH_SECRET to NEXTAUTH_SECRET, and the application worked normally.

Checks whether there is a variable with the incorrect name that vercel is unable to read.

@panu2109
Copy link

panu2109 commented Mar 3, 2024

@Syammed2429

Your problem may be in the environment variables.

I had the same problem:

Application error: a server-side exception has occurred (see the server logs for more information). Digest: 4286476458

I solved it by changing the name of the environment variable AUTH_SECRET to NEXTAUTH_SECRET, and the application worked normally.

Checks whether there is a variable with the incorrect name that vercel is unable to read.

@Syammed2429

Your problem may be in the environment variables.

I had the same problem:

Application error: a server-side exception has occurred (see the server logs for more information). Digest: 4286476458

I solved it by changing the name of the environment variable AUTH_SECRET to NEXTAUTH_SECRET, and the application worked normally.

Checks whether there is a variable with the incorrect name that vercel is unable to read.

i am facing the same issuee it would be great if u help me bro

@Icegreeen
Copy link

@Syammed2429
Your problem may be in the environment variables.

i am facing the same issuee it would be great if u help me bro

send the log so I can help you with your error and the two environment variables, production and dev environment

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Screenshot 2024-03-03 210700
sure bro here is the vercel logs

@panu2109
Copy link

panu2109 commented Mar 3, 2024

@Syammed2429
Your problem may be in the environment variables.

i am facing the same issuee it would be great if u help me bro

send the log so I can help you with your error and the two environment variables, production and dev environment

sas
please check out this

@panu2109
Copy link

panu2109 commented Mar 3, 2024

@Syammed2429
Your problem may be in the environment variables.

i am facing the same issuee it would be great if u help me bro

send the log so I can help you with your error and the two environment variables, production and dev environment

josh env

pranit

@Syammed2429
Copy link
Author

Guys whoever facing the issue please refer here

https://discord.com/channels/752553802359505017/1167434854703579176

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Guys whoever facing the issue please refer here

https://discord.com/channels/752553802359505017/1167434854703579176

did u solve the issue bro?

@Syammed2429
Copy link
Author

Guys whoever facing the issue please refer here

https://discord.com/channels/752553802359505017/1167434854703579176

did u solve the issue bro?

Yes, I did solved it

@Syammed2429
Copy link
Author

Guys whoever facing the issue please refer here

https://discord.com/channels/752553802359505017/1167434854703579176

did u solve the issue bro?

Wait till tomorrow here already midnight so tomorrow I'll check my code-base and give the the code

@panu2109
Copy link

panu2109 commented Mar 3, 2024

https://discord.com/channels/752553802359505017/1167434854703579176

yes sir please it would be a great help me to...as i want to submit my project please try to provide me the code

@Syammed2429
Copy link
Author

https://discord.com/channels/752553802359505017/1167434854703579176

yes sir please it would be a great help me to...as i want to submit my project please try to provide me the code

Sure please wait hehe

@panu2109
Copy link

panu2109 commented Mar 3, 2024

https://discord.com/channels/752553802359505017/1167434854703579176

yes sir please it would be a great help me to...as i want to submit my project please try to provide me the code

Sure please wait hehe

were u deploying in vercel?

@Syammed2429
Copy link
Author

https://discord.com/channels/752553802359505017/1167434854703579176

yes sir please it would be a great help me to...as i want to submit my project please try to provide me the code

Sure please wait hehe

were u deploying in vercel?

Yes I did deployed on vercel as well as on aws

@Syammed2429
Copy link
Author

https://discord.com/channels/752553802359505017/1167434854703579176

yes sir please it would be a great help me to...as i want to submit my project please try to provide me the code

Sure please wait hehe

were u deploying in vercel?

Btw are you using nextjs or other framework?

@panu2109
Copy link

panu2109 commented Mar 3, 2024

https://discord.com/channels/752553802359505017/1167434854703579176

yes sir please it would be a great help me to...as i want to submit my project please try to provide me the code

Sure please wait hehe

were u deploying in vercel?

Btw are you using nextjs or other framework?

Next.js sir

@Icegreeen
Copy link

@Syammed2429

pranit

about the varible resend_api_key, which service are you using?

Which service is not running in your production application? needing to identify which service is not working to investigate the configuration of its environment variable.

Your problem is an environment variable that is not being read by Vercel due to an incorrect description, name or configuration.

@panu2109
Copy link

panu2109 commented Mar 3, 2024

@Syammed2429

pranit

about the varible resend_api_key, which service are you using?

Which service is not running in your production application? needing to identify which service is not working to investigate the configuration of its environment variable.

Your problem is an environment variable that is not being read by Vercel due to an incorrect description, name or configuration.

about resend_api_key sir...i am using resend.com service

@panu2109
Copy link

panu2109 commented Mar 3, 2024

@Syammed2429

pranit

about the varible resend_api_key, which service are you using?

Which service is not running in your production application? needing to identify which service is not working to investigate the configuration of its environment variable.

Your problem is an environment variable that is not being read by Vercel due to an incorrect description, name or configuration.

how do i check sir can u eloborate

@panu2109
Copy link

panu2109 commented Mar 3, 2024

@Syammed2429

pranit

about the varible resend_api_key, which service are you using?

Which service is not running in your production application? needing to identify which service is not working to investigate the configuration of its environment variable.

Your problem is an environment variable that is not being read by Vercel due to an incorrect description, name or configuration.

do u have any solution please provide me

@Icegreeen
Copy link

Icegreeen commented Mar 3, 2024

do u have any solution please provide me

Just the https://resend.com/ email sending service is not working?

Well, let's go. See here in one of my applications in which I use resend, see that I am using other variables, which are:

the user
the password
the host
the door
and the address origin

Captura de tela de 2024-03-03 13-43-39

@Icegreeen
Copy link

you are only using one
Captura de tela de 2024-03-03 14-14-39

@panu2109
Copy link

panu2109 commented Mar 3, 2024

do u have any solution please provide me

Just the https://resend.com/ email sending service is not working?

Well, let's go. See here in one of my applications in which I use resend, see that I am using other variables, which are:

the user the password the host the door and the address origin

Captura de tela de 2024-03-03 13-43-39

i didnt get sir

@panu2109
Copy link

panu2109 commented Mar 3, 2024

you are only using one Captura de tela de 2024-03-03 14-14-39

can u provide me ur insta profile so i can talk to u there?please its urgent

@panu2109
Copy link

panu2109 commented Mar 3, 2024

do u have any solution please provide me

Just the https://resend.com/ email sending service is not working?

Well, let's go. See here in one of my applications in which I use resend, see that I am using other variables, which are:

the user the password the host the door and the address origin

Captura de tela de 2024-03-03 13-43-39

email service is working

@panu2109
Copy link

panu2109 commented Mar 3, 2024

do u have any solution please provide me

Just the https://resend.com/ email sending service is not working?
Well, let's go. See here in one of my applications in which I use resend, see that I am using other variables, which are:
the user the password the host the door and the address origin
Captura de tela de 2024-03-03 13-43-39

i didnt get sir

???

@Icegreeen
Copy link

do u have any solution please provide me

Just the https://resend.com/ email sending service is not working?
Well, let's go. See here in one of my applications in which I use resend, see that I am using other variables, which are:
the user the password the host the door and the address origin
Captura de tela de 2024-03-03 13-43-39

i didnt get sir

???

I need to know which service in your software is not working so I can help you. Until now I don't understand which service is not working causing that error.

@panu2109
Copy link

panu2109 commented Mar 3, 2024

do u have any solution please provide me

Just the https://resend.com/ email sending service is not working?
Well, let's go. See here in one of my applications in which I use resend, see that I am using other variables, which are:
the user the password the host the door and the address origin
Captura de tela de 2024-03-03 13-43-39

i didnt get sir

???

I need to know which service in your software is not working so I can help you. Until now I don't understand which service is not working causing that error.

in locally the project just works fine...but while deploying in vercel it causes this error

@panu2109
Copy link

panu2109 commented Mar 3, 2024

yes, but your application has an address that is in production, right?
When accessing, which service is not working?

sir..after deploying immediately the page pops up

sss
hope sir..u got my point

@Icegreeen
Copy link

Are you using any authentication service in your application? like authjs?

@Icegreeen
Copy link

Are you using an ORM, like Prisma?

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Are you using an ORM, like Prisma?

using mongodb

@Icegreeen
Copy link

Are you using an ORM, like Prisma?

using mongodb

mongobd is database.

Copy the contents of your package.json file here for me

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Are you using an ORM, like Prisma?

using mongodb

mongobd is database.

Copy the contents of your package.json file here for me

{
"name": "digitalhippo",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
"build:server": "tsc --project tsconfig.server.json",
"build:next": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NEXT_BUILD=true node dist/server.js",
"build": "cross-env NODE_ENV=production yarn build:payload && yarn build:server && yarn copyfiles && yarn build:next",
"start": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
"copyfiles": "copyfiles -u 1 "src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}" dist/",
"lint": "next lint"
},
"resolutions": {
"cliui": "7.0.2"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@payloadcms/bundler-webpack": "^1.0.6",
"@payloadcms/db-mongodb": "^1.3.2",
"@payloadcms/richtext-slate": "^1.3.1",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@react-email/components": "^0.0.15",
"@tanstack/react-query": "4.36.1",
"@trpc/client": "^10.45.0",
"@trpc/next": "^10.45.0",
"@trpc/react-query": "^10.45.0",
"@trpc/server": "^10.45.0",
"body-parser": "^1.20.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cross-env": "^7.0.3",
"date-fns": "^3.3.1",
"dotenv": "^16.3.2",
"express": "^4.18.2",
"lucide-react": "^0.312.0",
"next": "^14.1.1",
"nodemailer": "^6.9.9",
"payload": "^2.8.2",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.50.0",
"resend": "^3.2.0",
"sonner": "^1.4.0",
"stripe": "^14.17.0",
"swiper": "^11.0.6",
"tailwind-merge": "^2.2.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.4",
"zustand": "^4.5.1"
},
"devDependencies": {
"@types/express": "^4.17.21",
"@types/node": "^20",
"@types/nodemailer": "^6.4.14",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"copyfiles": "^2.4.1",
"eslint": "^8",
"eslint-config-next": "14.0.4",
"nodemon": "^3.0.3",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}

@Icegreeen
Copy link

Now send me the content in the .env file (Remove the keys)

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Now send me the content in the .env file (Remove the keys)

sure wait

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Now send me the content in the .env file (Remove the keys)

PAYLOAD_SECRET=
MONGODB_URL=
NEXT_PUBLIC_SERVER_URL=

STRIPE_SECRET_KEY=

RESEND_API_KEY=

@Icegreeen
Copy link

Note that, for resend to work, you need these other environment variables to be added?

Captura de tela de 2024-03-03 15-08-27

@Icegreeen
Copy link

Icegreeen commented Mar 3, 2024

I don't know if you don't understand, but some client side service is not working due to some variable not being read by vercel in a production environment

that's why it gives that error

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Note that, for resend to work, you need these other environment variables to be added?

Captura de tela de 2024-03-03 15-08-27

okay bro..i will do that but,,i did'nt add these variables because i am following the tutorial on yt...that guy didnt add any of these...but i "ll add and see what goes on

@panu2109
Copy link

panu2109 commented Mar 3, 2024

I don't know if you don't understand, but some client side service is not working due to some variable not being read by vercel in a production environment

that's why it gives that error

is it sure that because of this..resend.com variables not added thats why it is giving me the error

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Note that, for resend to work, you need these other environment variables to be added?

Captura de tela de 2024-03-03 15-08-27

one more thing in locally with one only resend api key...the email i was able to send to the users

@Icegreeen
Copy link

Redeploy your application after adding the variables.

You have to see that tutorial is old, and the requirements there do not resend production variables.

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Redeploy your application after adding the variables.

You have to see that tutorial is old, and the requirements there do not resend production variables.

okay sir i'll add the variables of env and let u know

@panu2109
Copy link

panu2109 commented Mar 3, 2024

Note that, for resend to work, you need these other environment variables to be added?
Captura de tela de 2024-03-03 15-08-27

one more thing in locally with one only resend api key...the email i was able to send to the users

and the variable of email from...i will have to put my email right?The one i have verified my domain...

@panu2109
Copy link

panu2109 commented Mar 3, 2024

import dotenv from "dotenv"
import path from "path"
import payload, { Payload } from "payload"
import type { InitOptions } from "payload/config"
import nodemailer from 'nodemailer'

dotenv.config({
path: path.resolve(__dirname,"../.env"),
})

const transporter = nodemailer.createTransport({
host:"smtp.resend.com",
secure:true,
port: 465,
auth:{
user: "resend",
pass: process.env.RESEND_API_KEY
}
})

let cached = (global as any).payload

if(!cached){
cached = (global as any).payload = {
client : null,
promise : null,
}
}
interface Args{
initOptions? : Partial
}

export const getPayloadClient = async ({
initOptions,
}: Args = {}): Promise=> {
if(!process.env.PAYLOAD_SECRET){
throw new Error('PAYLOAD_SECRET is missing')
}

if(cached.client){
    return cached.client
}

if(!cached.promise){
    cached.promise = payload.init({
        email:{
            transport: transporter,
            fromAddress:"[email protected]",
            fromName: "DigitalHippo",
        },

        secret: process.env.PAYLOAD_SECRET,
        local: initOptions?.express? false : true,
        ...(initOptions || {}), 
    })
} 

try{
    cached.client = await cached.promise
} catch (e : unknown){
    cached.promise = null
    throw e
}

return cached.client

} this is the code of resend.com please have a look..

@Icegreeen
Copy link

but this code is back-end, right? your problem is client side.

@Icegreeen
Copy link

Icegreeen commented Mar 3, 2024

@Syammed2429

Your problem may be in the environment variables.

I had the same problem:

Application error: a server-side exception has occurred (see the server logs for more information). Digest: 4286476458

I solved it by changing the name of the environment variable AUTH_SECRET to NEXTAUTH_SECRET, and the application worked normally.

Checks whether there is a variable with the incorrect name that vercel is unable to read.

As I mentioned here, try to check which services you are using next to the client and consider adding NEXT or NEXT_ in front of the name of the environment variable in the vercel settings.

And deploy it to your application to see if it works.

@panu2109
Copy link

panu2109 commented Mar 3, 2024

but this code is back-end, right? your problem is client side.

oh i got ur point now...

@panu2109
Copy link

panu2109 commented Mar 3, 2024

@Syammed2429
Your problem may be in the environment variables.
I had the same problem:
Application error: a server-side exception has occurred (see the server logs for more information). Digest: 4286476458
I solved it by changing the name of the environment variable AUTH_SECRET to NEXTAUTH_SECRET, and the application worked normally.
Checks whether there is a variable with the incorrect name that vercel is unable to read.

As I mentioned here, try to check which services you are using next to the client and consider adding NEXT or NEXT_ in front of the name of the environment variable in the vercel settings.

And deploy it to your application to see if it works.

okay bro i will check this tomorrow..thank u so much for this help,..YOU ARE A GREAT GUY!!!!

@panu2109
Copy link

panu2109 commented Mar 3, 2024

@Syammed2429
Your problem may be in the environment variables.
I had the same problem:
Application error: a server-side exception has occurred (see the server logs for more information). Digest: 4286476458
I solved it by changing the name of the environment variable AUTH_SECRET to NEXTAUTH_SECRET, and the application worked normally.
Checks whether there is a variable with the incorrect name that vercel is unable to read.

As I mentioned here, try to check which services you are using next to the client and consider adding NEXT or NEXT_ in front of the name of the environment variable in the vercel settings.

And deploy it to your application to see if it works.

if any problem persists hope u willl help me :)..thank u once again

@panu2109
Copy link

panu2109 commented Mar 4, 2024

Guys whoever facing the issue please refer here

https://discord.com/channels/752553802359505017/1167434854703579176

did u solve the issue bro?

Wait till tomorrow here already midnight so tomorrow I'll check my code-base and give the the code

Sir????

@Selvagokul
Copy link

Application error: a server-side exception has occurred (see the server logs for more information).
Digest: 2346791077 i am using prisma

@urah001
Copy link

urah001 commented Jul 17, 2024

this error appear when you want to deploy your project .
how i fixed mine was .

i used nextjs and supabase

Enter Key-Value Pairs:

  1. NEXT_PUBLIC_SUPABASE_URL : Enter NEXT_PUBLIC_SUPABASE_URL as the key and your Supabase URL as the value.
  2. NEXT_PUBLIC_SUPABASE_ANON_KEY : Enter NEXT_PUBLIC_SUPABASE_ANON_KEY as the key and your Supabase anonymous key as the value.
  3. SUPABASE_SERVICE_KEY : Enter SUPABASE_SERVICE_KEY as the key and your Supabase service key as the value (ensure this key is used only on the server side).

after entering this values pair , it would work , atleast for me , to locate where you would enter this values .

To set your environment variables in Vercel, follow these steps:

Guide to Setting Environment Variables in Vercel

  1. Access Vercel Dashboard:

    • Go to the Vercel Dashboard.
    • Log in with your Vercel account if you haven't already.
  2. Select Your Project:

    • From the dashboard, click on the project you want to configure.
  3. Navigate to Project Settings:

    • On the left-hand menu, click on "Settings."
  4. Open Environment Variables Section:

    • In the settings menu, scroll down to the "Environment Variables" section.
  5. Add Environment Variables:

    • Click on the "Add" button to add a new environment variable.
  6. Enter Key-Value Pairs:

    • NEXT_PUBLIC_SUPABASE_URL: Enter NEXT_PUBLIC_SUPABASE_URL as the key and your Supabase URL as the value.
    • NEXT_PUBLIC_SUPABASE_ANON_KEY: Enter NEXT_PUBLIC_SUPABASE_ANON_KEY as the key and your Supabase anonymous key as the value.
    • SUPABASE_SERVICE_KEY: Enter SUPABASE_SERVICE_KEY as the key and your Supabase service key as the value (ensure this key is used only on the server side).
  7. Specify Environment (Optional):

    • You can choose to set these variables for specific environments (e.g., Production, Preview, Development). If not specified, the variables will be available in all environments.
  8. Save Changes:

    • After entering the key-value pairs, click on the "Save" button to apply the changes.

Example of Adding Environment Variables

Here's how it should look:

  • Key: NEXT_PUBLIC_SUPABASE_URL
    • Value: https://your-project.supabase.co
  • Key: NEXT_PUBLIC_SUPABASE_ANON_KEY
    • Value: your-anonymous-key
  • Key: SUPABASE_SERVICE_KEY
    • Value: your-service-key

@Omprakash1353
Copy link

Don't know why but I m get server side exception error in my code can anybody let me know why is this happening. I have once tried deploying code on vercel it works fine but when I tried deploying the same code on aws amplify it through the Application server side accepting error can anybody help me out plz.... I m using nextjs with nextauth and mongodb

@Omprakash1353
Copy link

Application error: a server-side exception has occurred (see the server logs for more information).
Digest: 2346791077 i am using prisma

Can you tell me how can I solve this issue if you already have solved it.

@giovannefeitosa
Copy link

I'm late to the party but I just experienced this issue using Next.js 14 and Supabase, my project is less than two weeks old and I spent some time trying to solve it. No other solutions worked for me until I found this link:

https://supabase.com/docs/guides/auth/server-side/nextjs

I had to change my middleware and create server client function

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

7 participants