Skip to content

Webpack5 enabled API Route return Internal Server Error when deployed to vercel, but works fine locally #23894

@agustinusnathaniel

Description

@agustinusnathaniel

What version of Next.js are you using?

10.1.3

What version of Node.js are you using?

14.15.3

What browser are you using?

Chrome

What operating system are you using?

Windows 10

How are you deploying your application?

Vercel

Describe the Bug

I have a project which have an API route which returns collection of data from markdowns using gray-matter. Works fine locally and when deployed to vercel. But problem occurs when I enable the webpack5 configuration in next.config.js, now the api route works fine locally, but it returns ISE (Internal Server Error) when deployed to vercel.

Expected Behavior

The api route should works fine locally and when being deployed to vercel with webpack5 enabled.

To Reproduce

Sample Repository to reproduce: https://github.com/sozonome/nextjs-webpack5-api-route-vercel-deployment-error
https://github.com/sozonome/nextjs-webpack5-api-route-vercel-deployment-error/blob/main/next.config.js

Expected (local dev screenshot):
image

Deployed (in vercel):
https://nextjs-webpack5-api-route-vercel-deployment-error.vercel.app/api/posts
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions