Next.js Discord

Discord Forum

Astro project with middleware does work locally, but does not work at all when deployed to Vercel.

Unanswered
Black and Tan Coonhound posted this in #help-forum
Open in Discord
Black and Tan CoonhoundOP
Hi, I'm having trouble with deploying my Astro project with Middleware to Vercel.

My middleware works locally but doesn't run when deployed to Vercel. I suspect the problem is Vercel not running the middleware.mjs file, but I am left completely clueless on what to do to fix this.

I've been looking everywhere, checking Astro GitHub issues for solutions or updates on some related discussions I'd found, but I couldn't find any.

If it's important to take into a count, this is my npx astro info:

Astro                    v4.8.6
Node                     v20.12.1
System                   Windows (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/vercel/serverless
Integrations             @astrojs/tailwind
                         astro:db
                         @astrojs/db/file-url
                         @astrojs/react
                         astro-auth


I'll leave a list of things I've tested to no success to fix my issue:

List of things I've tried:
- Looked for web console errors in the Console section --> found none.

- Looked into theNetwork section, found I get the error with Status 500 when accessing /api/ endpoints (e.g '/api/signup.ts', '/api/github.ts'). The embedded screenshot is in spanish but I think it's still readable and understandable.

- Looked up my middleware.ts code, checked any possible errors --> found none, the code was copy pasted from Lucia-auth docs.

What I'm trying to accomplish is to keep testing my project while deployed in Vercel but I get stuck in this loop I can't get out of and I can't seem to find any information that could help me out.

Any kind of help would be very much appreciated,
Thanks in advance

0 Replies