getting unauthorized in production but locally works flawless
Hello. Im trying to implement a user check in one of my api endpoints in Hono to prevent abuse.
The whole auth flow was setup on nextjs side (logging in, signing up etc.). But i neeed separate backend to manage high uploads.
And the problem rises when trying to fetch that protected endpoint. I fetch it client-side with credentials "include" to attach the cookies. After fetching, i always get 401, and the credentials are set to "omit" for some reason. This didn't happen in local.
Here's the fetch call:
Here's the server configuration:
And heres the endpoint: /v1/auth/upload:
Solution:Jump to solution
Got it working now after 7 hours. I needed to hard reset browser and remove all cookies for this to work. Something weird probably cached. The code was good.
6 Replies
Also, earlier in the app i implement an server-side check to get the session from the backend and it worked flawlessy. I just can't get the credentials to work. (clientside)
check cookie domain
You mean the domain in the auth config?
advanced: {
crossSubDomainCookies: {
enabled: true,
domain: ".domain.xyz",
}
},
This is what im using both client and server
nope devtools
Can't really tell you, because no cookies are sent to the server beacuse of the credentials "omit" instead of includes. Every other domain in the request is correct.
Solution
Got it working now after 7 hours. I needed to hard reset browser and remove all cookies for this to work. Something weird probably cached. The code was good.