onehalla / nextjs13-cors

A simple example of how to configure CORS in a NextJS 13 app using AppRouter.

Home Page:https://nextjs13-cors.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NextJS13 AppRouter Cors Configuration

A simple example of how to configure CORS in a NextJS 13 app using AppRouter.


Tutorial

This repo is part of tutorial article. You can find the Medium article here: NextJS 13 AppRouter Tutorial

NextJS App Router Working With Cors


Getting Started

Prerequisites

Installation

#FROM: /

pnpm install

NextJS Server

#FROM: /

pnpm dev

Client-Side App Server

#FROM: /

pnpm client

CORS Configurations

Option 1 - NextJS Config

You can find those cors configurations in next.config.js.

Option 2 - Route Handler

You can find those cors configurations in pages/api/users/route.ts.

Option 3 - Middleware CORS Configurations

You can find those cors configurations in middleware.ts.


built by @codingwithmanny

About

A simple example of how to configure CORS in a NextJS 13 app using AppRouter.

https://nextjs13-cors.vercel.app


Languages

Language:TypeScript 57.7%Language:JavaScript 28.9%Language:HTML 13.4%