Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-cors

Package Overview
Dependencies
Maintainers
8
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-cors - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

2

index.d.ts

@@ -6,3 +6,3 @@ /// <reference types="node" />

type OriginCallback = (err: Error | null, allow: boolean) => void;
type OriginFunction = (origin: string, callback: OriginCallback) => void;
export type OriginFunction = (origin: string, callback: OriginCallback) => void;
type OriginType = string | boolean | RegExp;

@@ -9,0 +9,0 @@ type ValueOrArray<T> = T | ArrayOfValueOrArray<T>;

{
"name": "fastify-cors",
"version": "4.0.0",
"version": "4.1.0",
"description": "Fastify CORS",

@@ -35,11 +35,11 @@ "main": "index.js",

"devDependencies": {
"@types/node": "^13.13.4",
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.0.0",
"@types/node": "^14.0.1",
"@typescript-eslint/eslint-plugin": "^3.0.1",
"@typescript-eslint/parser": "^3.0.1",
"cors": "^2.8.5",
"fastify": "^3.0.0-rc.1",
"fastify": "^3.0.0",
"standard": "^14.0.2",
"tap": "^14.10.7",
"typescript": "^3.5.3",
"tsd": "^0.11.0"
"tsd": "^0.13.1"
},

@@ -46,0 +46,0 @@ "dependencies": {

@@ -8,3 +8,3 @@ # fastify-cors

Supports Fastify versions `3.x`
Please refer to [this branch](https://github.com/fastify/fastify-cors/tree/3.x) and related versions for Fastify `^3.x` compatibility.
Please refer to [this branch](https://github.com/fastify/fastify-cors/tree/3.x) and related versions for Fastify `^2.x` compatibility.
Please refer to [this branch](https://github.com/fastify/fastify-cors/tree/1.x) and related versions for Fastify `^1.x` compatibility.

@@ -11,0 +11,0 @@

import fastify from 'fastify'
import fastifyCors from '..'
import fastifyCors, {OriginFunction} from '..'

@@ -80,10 +80,12 @@ const app = fastify()

const corsDelegate: OriginFunction = (origin, cb) => {
if (typeof origin === 'undefined' || /localhost/.test(origin)) {
cb(null, true)
return
}
cb(new Error(), false)
};
app.register(fastifyCors, {
origin: (origin: string, cb: (err: Error | null, allow: boolean) => void) => {
if (/localhost/.test(origin) || typeof origin === 'undefined') {
cb(null, true)
return
}
cb(new Error(), false)
},
origin: corsDelegate,
allowedHeaders: ['authorization', 'content-type'],

@@ -176,4 +178,4 @@ methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],

appHttp2.register(fastifyCors, {
origin: (origin: string, cb: (err: Error | null, allow: boolean) => void) => {
if (/localhost/.test(origin) || typeof origin === 'undefined') {
origin: (origin: string | undefined, cb: (err: Error | null, allow: boolean) => void) => {
if (typeof origin === 'undefined' || /localhost/.test(origin)) {
cb(null, true)

@@ -180,0 +182,0 @@ return

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc