I am trying to access my Preview environment, the deployment is happening fine, I am able to access the login screen in the preview env but when I am trying to login, it is throwing error. It seems like it is unable to access the data to verify my login.
Hey @laneapp24. I think you’re talking about Vercel’s Deployment Protection screen in front of your preview deployment. If you first log in at vercel.com/login and then visit the preview deployment in the same browser, does that let you access the preview deployment?
If it’s a separate login screen, such as something set up using NextAuth.js that’s failing in the preview environment, that could be caused by a missing or expired environment variable. In that case I would recommend double checking that all preview environment variable values to be sure they match what’s expected by your auth service.
@amyegan
Yes, I just turned the Deployment protection off and it seems to work fine now. [Thanks for this]
But what could be the reason it was not working in when DP was enabled?
Vercel Authentication needs you to be logged so it can determine whether you can access a deployment. I’m not sure why you were unable to log in. If you were already logged in to the browser, an additional login should not be needed. If you share the error info, I can try to dig for more details about what went wrong.
So, I checked.
I have two projects hosted- Backend and Frontend
If I have the frontend protected and backend unprotected then it is working fine
Or else, if I turn the DP on for the backend project, I am able to access my Sign in screen but unable to login in
The error:
…as been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Failed to load resource: net::ERR_FAILED
It sounds like there’s is a CORS configuration issue preventing the frontend from communicating with the backend. Here’s the guide to help you get the necessary headers added.