• Stars
    star
    222
  • Rank 179,123 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎉 nextjs-cors is a node.js package to provide a Connect/Express middleware that can be used to enable CORS with various options 🚀

Nextjs Cors

Nextjs-Cors is a node.js package to provide a middleware that can be used to enable CORS with various options in nextjs applications.

CI NPM Version Package License NPM Downloads

Installation

First we will have to install, in order to use this wonderful package.

# Using npm
npm install --save nextjs-cors@latest

# Using yarn
yarn add nextjs-cors@latest

# Using pnpm
pnpm add nextjs-cors@latest

Usage

nextjs-cors uses the cors package, so we invite you to check the documentation https://github.com/expressjs/cors

pages/api/whoami.{ts,js}

import NextCors from 'nextjs-cors';

async function handler(req, res) {
   // Run the cors middleware
   // nextjs-cors uses the cors package, so we invite you to check the documentation https://github.com/expressjs/cors
   await NextCors(req, res, {
      // Options
      methods: ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'],
      origin: '*',
      optionsSuccessStatus: 200, // some legacy browsers (IE11, various SmartTVs) choke on 204
   });

   // Rest of the API logic
   res.json({ message: 'Hello NextJs Cors!' });
}

Support for

nextjs-cors is an open source project licensed by MIT. You can grow thanks to the sponsors and the support of the amazing sponsors. If you want to join them, contact me here.

Stay in touch

Contributors

Thanks to the wonderful people who collaborate with me !

License

nextjs-cors under License.

More Repositories

1

sass-colors

🎨 Sass-colors 🌐 is a scss library, which adds modern colors.
SCSS
12
star
2

nestjs-sequelize-paginate

🎉 Pagination response object function + types for sequelize + nestjs
TypeScript
10
star
3

next-base64

base64 decoder and encoder for nextjs 🎉
TypeScript
8
star
4

dotfast

Dotfast helps to play with the keys nested in the objects, in a very easy way, and with very little code !
TypeScript
5
star
5

is-all-utils

Some functions to validate the type, and they are very light; take a look at the documentation!
JavaScript
5
star
6

tags-html

📖 List of all standard HTML5 tags 😄
TypeScript
5
star
7

my-nextjs-blog

🌍 Blog with Nextjs, and Write using Markdown 🎂
JavaScript
4
star
8

ts-has

JavaScript
4
star
9

yonycalsin.com

🚀 My personal Website 🎉 https://www.yonycalsin.com
TypeScript
4
star
10

cregex

☕ Regular validation expressions (regex) for javascript🎉
JavaScript
4
star
11

merge-options-default

Merged all options (object) with the default!
JavaScript
4
star
12

cbscroll-top

💥 Take the user 🎁 to the top of the page with just one click 👍.
TypeScript
4
star
13

rxjs-init

🎂 Starting with RxJs 👍
TypeScript
4
star
14

cb-valid

👍 Validator very easy to use, and implement! 🏳‍🌈(email, url, password, .etc)
JavaScript
4
star
15

vue-tutorial

🎂 With this article I want to show how easy it is to start working 🌎 with Vue so you can see its simplicity. 😎
4
star
16

format-fast

format-fast is a function that allows you to replace certain words to make a text string dynamically, and very easily !
TypeScript
4
star
17

cbytes

🎁 Utility to analyze a byte to unit chain and vice versa, unit converter ‍🌈
TypeScript
4
star
18

animation-scroll.js

🎁 Modern scroll animation 🎂 and very easy to use! 😉
TypeScript
4
star
19

nestjs-sequelize-seeder

🌾 A simple extension library for nestjs sequelize to perform seeding.
TypeScript
4
star
20

coloryze

🚀 An online whiteboard for teams to ideate and brainstorm together. 🎉
TypeScript
3
star
21

nestjs-crud-sequelize

Crud for nestjs
TypeScript
3
star
22

iva-system-react

VAT system made with react !
JavaScript
3
star
23

real-time-notification-with-node

🎂 Real Time Notification 🚀 with Nodejs and Web 🌍 Push 🎁
JavaScript
3
star
24

merge-object-1

Created with CodeSandbox
JavaScript
3
star
25

cogenv

Cogenv is a module that loads environment variables from an .env file into cog.env or process.env
TypeScript
3
star
26

slugger

Slugifies a String 🎉
Svelte
3
star
27

get-target

builder's extractor of a class, for handling of decorators
JavaScript
3
star
28

merge-all-objects

JavaScript
3
star
29

width-text

🚀 A small utility to measure the width of the text or string in browsers that support the canvas API. 🐋
JavaScript
3
star
30

nodejs-firebase-crud

nodejs-firebase-crud
JavaScript
3
star
31

dotenv-crack

TypeScript
3
star
32

tower-of-hanoi-with-typescript

Created with CodeSandbox
TypeScript
3
star
33

paginate-with-javascript

Created with CodeSandbox
JavaScript
3
star
34

css3-colors

CSS
3
star
35

iva-system-cpp

vat system for taxes with c++ ✔
C++
3
star
36

bootstrap-container

CSS
3
star
37

release-based-workflow

JavaScript
3
star
38

number-betwen

Created with CodeSandbox
HTML
3
star
39

clsf

A function that merges given class names, no matter their format. Filters out invalid class names as well.
JavaScript
3
star
40

my-tools

TypeScript
2
star
41

design-patterns-in-typescript

TypeScript
2
star
42

sequelize-ts-cli

TypeScript
2
star
43

final-form-scroll-to-errors

Decorator for 🏁 Final Form that will attempt to apply focus to the first field with an error upon an attempted form submission.
TypeScript
2
star
44

prettier-config

2
star
45

dotenv-cloak

TypeScript
2
star
46

webpay-integration-in-nodejs

HTML
2
star
47

scroll-style

CSS
2
star
48

javascript-en-14-minutos

Javascript en 14 minutos
TypeScript
2
star
49

ms-tooly

TypeScript
2
star
50

deploy-simple-to-heroku

This is a very simple GitHub action that allows you to deploy to Heroku
JavaScript
2
star
51

tailwindcss-theme

TypeScript
2
star
52

frontend-interview-exercise

TypeScript
2
star
53

bencody

TypeScript
2
star
54

static-swagger-ui

TypeScript
2
star
55

dotenv-cloack

Dotenv cloack is a package that allows you to generate on file all environment variables without the value
TypeScript
2
star
56

react-typescript-vite-starter

TypeScript
2
star
57

golang-auth-with-jwt

Go
1
star
58

crypto-market

List all supported coins price, market cap, volume, and market related data
TypeScript
1
star
59

scripts

Shell
1
star
60

cog-sync

TypeScript
1
star
61

golang-prices-mock

Go
1
star
62

doctors-management-ts-mongodb

TypeScript
1
star
63

go-first-examples

Go
1
star
64

resume.yonycalsin.com

JavaScript
1
star
65

dart-wheater

Dart
1
star
66

new-blitz-app

TypeScript
1
star
67

flutter-stateless-test

Dart
1
star
68

test-nextjs-express-vercel

JavaScript
1
star
69

flutter-shoes-app

Dart
1
star
70

solid-typescript-starter

TypeScript
1
star
71

chakra-ui-kbar

TypeScript
1
star
72

insomniatool

JavaScript
1
star
73

svelte-vercel-example

JavaScript
1
star
74

YoutubeAuthNodeApp

Simple Express App in which We do Youtube Auth and display youtube subscribed channels
JavaScript
1
star
75

github-opencollective-contributors

TypeScript
1
star
76

rust-cloack

Rust
1
star
77

tooly

It is a set of tools that help us in our daily work.
TypeScript
1
star
78

arch-api

TypeScript
1
star
79

emotion-next-test

JavaScript
1
star
80

tailwindcss-clsx

TypeScript
1
star
81

packages-monorepo-starter

JavaScript
1
star
82

jet-ui

🏝 jet-ui
TypeScript
1
star
83

flexbox-fast

CSS
1
star
84

maps-tool

TypeScript
1
star
85

eslint-config

eslint config
TypeScript
1
star