15 Replies
I mean the github oauth button
but probs different problem from mine then
github oauth button works
can you show me ur server action?
that works on local right?
yep
everything works on local
mutationServerAction fails on deployment
if used on client, i.e. by calling via onClick
yeah weird af, we have very different scenarios but seems like a very similar bug
I guessed that Next updated smth (they had around 500 core changes for that version). And now next-on-pages fail to compile actions like that.
another notice. It took me a while to make the reproduction. I added Clerk auth during that time. When I found the version bug, i started removing stuff.
There still might be some stuff on browser end left, like cookies maybe?
you said you were making smth with auth
but this is just a wild guess now
im guessing it has something to do with redirect or revalidatePath (also has someting to do with redirect i assume)
yup it was it
basically, you cant use anything that redirects in a server action or it returns a 404
bad middleware maybe then? or smth similar cached away
Previous code:
Current code (that works): i changed the last part for return
then on client side i just navigate via
window.location.href = url
I was using location.refresh() 😄
then changed to useRouter hook
oh, I also had another strange thing. Instead of POSTing once. My deployment was making 2-8 requests instead. Some of which were instantly cancelled
client side navigation methodology doesnt really matter, the server side redirect fuxs things up, which im guessing what redirectPath does in some way
you can just fix by awaiting the mutation function then calling router.refresh manually
await mutationServerAction()
router.refresh()
and removing
revalidatePath
from the mutation function ofc
thats strange but not sure what could've caused it without looking at the exact codeI meant, that after running mutation once on client, it made 1 request in browser, but logged 2-8 requests to POST handler of that mutation on CF tail
which all returned 404s
well, I already replaced action with an API server handler
how do you tail exactly?
I tried both CLI and CF Pages > Deployments > Funtions > start live stream
on Dashboard you can click each request for more details (in most cases)
but it's pretty strange.
If you log N times in same action. It ends up as an array of messages on single request. But in this case. It was empty for me.
So the action didn't run at all, it was either not compiled, or had different url than client expected.
I'm probably giving up on using Next with Pages. My VPS deployments feel more stable.