Next.js Discord

Discord Forum

Nextjs app directory not works actions on Amplify...

Answered
Rampur Greyhound posted this in #help-forum
Open in Discord
Rampur GreyhoundOP
Hi everyone i have a Nextjs app deployed on Amplify... i have also an action that works right in local but it seems not works on amplify? Someone can help me?
Answered by Rampur Greyhound
The problem was on backend side how it was settup the domain field.
Close the question
View full answer

43 Replies

hi, the action is not being call or failed to call?
Rampur GreyhoundOP
the first!
it works in local with next build && next start?
Rampur GreyhoundOP
i have tried only in dev
try build & start
Rampur GreyhoundOP
if you remember my action is a simple action that check if exist a cookie
yes try it with production build in local and see if it works first
inside a useEffect right?
@Ray inside a useEffect right?
Rampur GreyhoundOP
Yes
I will let you know
ok
Rampur GreyhoundOP
it works fine with build && start
ah
let me invite a expert of amplify here
@B33fb0n3 here he is
Rampur GreyhoundOP
no problem sure
let see if @B33fb0n3 knows this 😆
@Ray ah
Rampur GreyhoundOP
you expected it not to work
Where I can see action log in Amplify ?
Haha thanks for the compliment. You are right, I am using amplify for all the backend stuff like auth, graphql, .. but actually not for hosting 🤫
Rampur GreyhoundOP
@Ray i have added more debug and the action is called but fails the method cookies()...
@Ray any error?
Rampur GreyhoundOP
So I don’t know why but when I use cookies method in production it returns a empty array… any suggestions?
@Ray Im not sure, I've never use amplify.
Rampur GreyhoundOP
You can confirm that I can read a cookie that a third party backend returns… a cookie secure and HttpOnly…. Read this cookie with an action
@Rampur Greyhound You can confirm that I can read a cookie that a third party backend returns… a cookie secure and HttpOnly…. Read this cookie with an action
sorry I don't understand? so you are trying to read the cookies from a third party backend in the server action?
@Ray sorry I don't understand? so you are trying to read the cookies from a third party backend in the server action?
Rampur GreyhoundOP
Yeah… I have a third party backend that set an auth cookie and I d like read it ….
So the domain is the same ….
App.myapp.com fe and api.myapp.com be
Rampur GreyhoundOP
I will try… in dev and local works … I don’t know if a next problem, backend problem or amplify 😅
should be amplify
or try deploy it on vercel
Rampur GreyhoundOP
I have just tried on vercel the same situation
@Rampur Greyhound I have just tried on vercel the same situation
the cookies are being set by the third party domain?
Rampur GreyhoundOP
Yes
oh
then you shouldn't be able to read it, because cookie only send with the same domain
but I wonder why it would work in local
Rampur GreyhoundOP
If I use different domain I should read it?
I don't think so
are you able to set it on your app?
Rampur GreyhoundOP
The problem was on backend side how it was settup the domain field.
Close the question
Answer