https://www.ory.sh/ logo
b

breezy-intern-48727

05/04/2022, 11:56 PM
Hello! Thanks for such a great identity solution. Does anyone have any examples of how to SSR the flows (in Next.js) but submit the forms client-side? Despite setting the cookie and
csrf_token
in the request body, I keep getting a CSRF error when submitting the form.
p

proud-plumber-24205

05/05/2022, 7:13 AM
@User make sure that the domain your browser is on is matching the cookie domain. Kratos sets a CSRF cookie as well and if those don't match it will fail the request.
b

breezy-intern-48727

05/05/2022, 8:13 AM
Thanks @User. I did reuse some code from the next-edge integration to modify the forwarded cookie properties (i.e cookie domain). Would this not work?
p

proud-plumber-24205

05/05/2022, 9:04 AM
Hi @User I see, so you are using the #cloud product. You need to run the proxy in front of your application - the ory integrations library does just that. I would recommend checking out this blog post https://www.ory.sh/login-spa-react-nextjs-authentication-example-api-open-source/
In production you can switch over to a Custom Domain name and use that instead of the proxy. Check out these resources: • https://www.ory.sh/docs/guides/cli/proxy-and-tunnelhttps://www.ory.sh/docs/guides/custom-domains
b

breezy-intern-48727

05/05/2022, 9:21 AM
Thanks once again @User. I am indeed using Ory Cloud. I'll take a look through those resources
👍 1
2 Views