Next.js Discord

Discord Forum

Cors error in production

Unanswered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
i hosted my next.js app on aws amplify and my server is hosted on elastic beanstalk , i have configured the environments variables properly also added the hosted URl of my nextjs on my server , as i have credentials true so i can't use wild card like using * so i need to properly give frontend url in cors origin that i did but it still throwing cors error where as my pre flight works fine ehen i added separate middleware for test flight option they return 200 but my main request throws a cors origin error


i have hosted many nextjs app but this my server is on different url , i want to know if there is any specific way to handle this cors error ?


// Handle CORS
App.use(cors({
origin: process.env.cors_origin,
credentials: true,
}));

1 Reply

Cape lionOP
same setup works fine in my localhost nextjs runs on 3000 while my nodejs app runs on 5500