Skip to content

How to enable cors in Nextjs 13 Route Handlers #47933

Answered by leerob
L-U-C-K-Y asked this question in Help
Discussion options

You must be logged in to vote

Added an example to the docs:

export async function GET(request: Request) {
  return new Response('Hello, Next.js!', {
    status: 200,
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
      'Access-Control-Allow-Headers': 'Content-Type, Authorization',
    }
  });
}

Replies: 15 comments 27 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
10 replies
@jgoux
Comment options

@davecarlson
Comment options

@minervabot
Comment options

@benjick
Comment options

@zouinekh
Comment options

Answer selected by leerob
Comment options

You must be logged in to vote
5 replies
@shaun-scale
Comment options

@cjmling
Comment options

@Rieranthony
Comment options

@axelvaindal
Comment options

@minervabot
Comment options

Comment options

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

@ameer-clara
Comment options

Comment options

You must be logged in to vote
1 reply
@ashbuilds
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@0xPT
Comment options

@buretto
Comment options

@Mandy9943
Comment options

Comment options

You must be logged in to vote
1 reply
@minervabot
Comment options

Comment options

You must be logged in to vote
1 reply
@cfirdayantij
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@mcgingras
Comment options

@fwextensions
Comment options

@PiedraFernando
Comment options

@allmors
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet