question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Next@12.0.0] API route 500'ing in production, works locally

See original GitHub issue

What version of Next.js are you using?

12.0.0

What version of Node.js are you using?

14.18.0

What browser are you using?

Firefox

What operating system are you using?

Windows

How are you deploying your application?

Vercel

Describe the Bug

I have a few api routes, and one of them is failing in production builds, but works fine locally. They work fine in previous stable version of next, 11.1.x.

image

Uncaught (in promise) Error: An error has occured: 500
    e useReviews.ts:32
    l runtime.js:63
    _invoke runtime.js:293
    S runtime.js:118
    Babel 6
    w useReviews.ts:21
    c useReviews.ts:59
    Ii React
    unstable_runWithPriority scheduler.production.min.js:18
    React 3
    D scheduler.production.min.js:16
    onmessage scheduler.production.min.js:12
    60053 scheduler.production.min.js:12
    Webpack 16

Expected Behavior

The API route should not 500 since it works locally.

To Reproduce

I am not exactly sure how to reproduce, but I am using an API route to fetch from a third-party API and return some json.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ijjkcommented, Oct 30, 2021

Hi, this has been updated in v12.0.2-canary.11 of Next.js, please update and give it a try!

Note: this still isn’t compatible with @sentry/nextjs so if that needs to be used outputFileTracing: false can be set in your next.config.js

1reaction
wadehammescommented, Oct 26, 2021

@ijjk ah! Good catch. I don’t think we are getting much use from Sentry on these low-level API routes so I think I’ll just remove it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API route works locally but not in production #8383 - GitHub
A clear and concise description of what the bug is. To Reproduce. Steps to reproduce the behavior, please provide code snippets or a...
Read more >
Nextjs api route internal error in production - Stack Overflow
All apis are working just fine when serving locally but when i try to deploy the app in vercel/ heroku, the apis give...
Read more >
API Routes: Introduction - Next.js
API routes provide a solution to build your API with Next.js. Any file inside the folder pages/api is mapped to /api/* and will...
Read more >
How to use Next.js API Routes? - Refine Dev
We will deep dive into Next.js API Routes with Dynamic Routes. ... Next.js is a React framework and platform for building production-grade, ......
Read more >
Environment Variables in Next.js - Frontend Digest
For local development, you need a file called .env.local which contains all environment variables available for API routes and your server. To make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found