#Vercel API with Remix

1 messages · Page 1 of 1 (latest)

pallid fulcrum
#

I am trying to get Vercel serverless functions running at packages/web/api/...

I have my remix app also at packages/web/app/...

packages/web/app/vercel.json contains:
{
"rewrites": [{ "source": "/api/(.*)", "destination": "/api" }]
}

when running with vercel dev, I don't see the routes being rewritten. Instead, they get to the remix server which 404s. What's the correct way to setup this rewrite with Vercel, in a monorepo setup?

buoyant tiger
#

Hey @pallid fulcrum! You should probably be using Remix's native Resource Routes (https://remix.run/docs/en/1.14.0/guides/resource-routes) to implement your API endpoints.

Unless there's a specific reason you want to use Vercel API functions (i.e. to use a runtime other than Node.js), I'd suggest sticking with the framework native way of doing it.

pallid fulcrum
#

Hey @buoyant tiger, I was indeed trying to get an existing express app running at the route by itself, but I couldn't figure out how to get the rewrite working, so I ended up porting the express app to resource routes as you said.

chilly crystal
buoyant tiger
#

@chilly crystal You can use the Vercel api directory alongside your Remix app. But the crons configuration should work with Remix resource routes as well - just specify the URL path to that endpoint in vercel.json.

chilly crystal
#

@buoyant tiger Thank you!