How to set up NextJS + API Server on Vercel #10
-
Continuing a discussion that @aeneasr and I had earlier. I'd like to workshop how one would use the Ory Proxy in a Vercel environment. Currently, Altair deploys its Next.js frontend to Vercel. The frontend lives in a monorepo with our design system and other related packages. Here's a screenshot of the deployment settings from Vercel. It's pretty straightforward. Dependencies are built, and the main app is built and deployed. Preview builds, like those generated alongside a pull request are hosted at We've talked about hosting the proxy somewhere in a container, but more specifics on that would be great. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Thank you for the explanation! So there are a few layers to this:
So in general you want to protect your API server from unauthorized access. The easiest way to do that is to use the Ory Proxy. Here, you can follow two patterns:
The third option would be for us (Ory) to provide the proxy as an NPM package which would allow you to do in your package.json
Regardless of which path you chose, in your UI you would then set up the Ory SDK like so:
I believe that should be all you need to get this to work on vercel. On problem could be that the deployment previews do not work. The problem being that you are on separate domains - so altair.tv and vercel.app. I am not sure if vercel allows you to set up previews on your CNAME? Theoretically, it is still possible to configure this to work cross-domains. But it is quite likely that it will break in a few months or a year when FireFox or Chrome bring out new cookie rules. |
Beta Was this translation helpful? Give feedback.
Thank you for the explanation! So there are a few layers to this:
So in general you want to protect your API server from unauthorized access. The easiest way to do that is to use the Ory Proxy. Here, you can follow two patterns:
…