Closed abcd-ca closed 1 year ago
I've tried with and without NextJS but no luck. Here's a repo fully set up if anyone wants to pitch in and try to get it working.
I think you're required to publish this files on pages/api
.
@alexevladgabriel with a vanilla Vercel app the docs say /api. In a NextJS app it’s /pages/api. I have tried each and both concurrently. I’ve gotten to to work locally to some degree but it won’t deploy. With NextJS locally the rust endpoints interfere with it he js api endpoints though. Vercel is now helping me. I’ll update if I have more info
I got it working, turns out I just needed to update my Vercel CLI 🤦 🎉
I'm now using Vercel CLI 28.16.7
and before I was on a lower 28.x.x
. I forget the Xs but major number was definitely 28.
Here's a working repo with a NextJS project:
git clone https://github.com/abcd-ca/vercel-nextjs-rust
vercel --prod
- accept all the defaults<url from deployment>/api/hellojs
<url from deployment>/api/hellorust
To get it to work locally, there's a trick, though I've been discussing this with Vercel and a ticket has been submitted with the Vercel CLI team which I expect will streamline this:
vercel dev --debug
Look for a line that contains Spawning dev command: next dev --port 50434
. The port number differ from this one but it shows that the NextJS API endpoints are running on a different port than the Rust API endpoints which are on port 3000
(Thanks to Vercel for this tip)http://localhost:50434/api/hellojs
http://localhost:3000/api/hellorust
Given the example on the root page, I initially couldn't run
vercel dev
without a build error. I commented out the[lib]
section in /api/Cargo.toml and thenvercel dev
did work and served up "hello world" at http://localhost:3000/api/userThen I tried to deploy it using
vercel
. It failed in my terminal window with,And in the Vercel logs, I see,