Skip to content
Discussion options

You must be logged in to vote

Since GET requests are eligible for pre-renderingwhatever, you can easily opt out of that with connection:

import { connection, type NextRequest } from 'next/server';

export async function GET(req: NextRequest) {
  await connection();
  // ...
}

During the build step the GET function is still going to be called, so make sure you call await connection early. The best place to do it is right before introducing any side-effects (or doing dynamic IO) so the rest is still verified during build.

Replies: 3 comments 9 replies

Comment options

You must be logged in to vote
2 replies
@arjunkomath
Comment options

@icyJoseph
Comment options

Comment options

You must be logged in to vote
5 replies
@arjunkomath
Comment options

@dieguezz
Comment options

@arjunkomath
Comment options

@dieguezz
Comment options

@arjunkomath
Comment options

Comment options

You must be logged in to vote
2 replies
@arjunkomath
Comment options

@icyJoseph
Comment options

Answer selected by arjunkomath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants