Edge Function middleware is referencing unsupported modules
Asked Answered
G

3

7

Im trying to deploy a storybook on vercel and get the following message error:

enter image description here

the project uses pnpm as package manager. Ive upgraded the last version of NextJs and Clerk, as well as downgrade NextJs, but the build is still crashing.

I found this thread unsupported modules, I tried all the paths discussed there, but I'm still having the same issue.

This is my middleware.ts file:

import { authMiddleware } from '@clerk/nextjs';
import { NextResponse } from 'next/server';
import type { NextFetchEvent, NextRequest } from 'next/server';

export default authMiddleware({
  //@ts-ignore
  afterAuth(auth, req: NextRequest, evt: NextFetchEvent) {
    // handle users who aren't authenticated
    if (!auth.userId && !auth.isPublicRoute) {
      const signInUrl = new URL('/sign-in', req.url);
      // signInUrl.searchParams.set('redirect_url', req.url);
      return NextResponse.redirect(signInUrl);
    }
  },
});

export const config = {
  matcher: ['/((?!.*\\..*|_next).*)', '/', '/(api|trpc)(.*)'],
};

I played with framework presets at vercel too.

enter image description here

I changed NextJs to Storybook, but no luck :(

enter image description here

I hope sb can provide a workaround or nice solution. :)

Gittel answered 7/8, 2023 at 21:17 Comment(0)
A
4

I got the same issue and found something in GitHub

Go to your Project Settings > Build & Development Settings, change the framework presets from Others to Next.js, and do a new deployment to work!

Apostles answered 22/3, 2024 at 3:12 Comment(1)
Thank you! This really helped me because the Type of my project was "Other" once I imported my GitHub repo and only after that I've installed the Next.js into it.Gazehound
C
1

Downgrade nextjs version to 13.4.3

I had similar error about unsupported modules in middeleware.ts file. Downgrading the nextjs version worked for me.

Cayman answered 12/9, 2023 at 19:14 Comment(0)
F
0

I just had this exact issue, and it seems to be solved now. I first tried to deploy it as a non-framework static web app with custom build commands. But by removing all of the custom commands, and setting the framework to "Storybook" instead of "Other", everything worked out of the box without any custom setup etc!

Frore answered 19/10, 2023 at 10:19 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.