Socket
Socket
Sign inDemoInstall

@fastify/cors

Package Overview
Dependencies
Maintainers
20
Versions
17
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 8.4.0 to 8.4.1

3

package.json
{
"name": "@fastify/cors",
"version": "8.4.0",
"version": "8.4.1",
"description": "Fastify CORS",
"main": "index.js",
"type": "commonjs",
"types": "types/index.d.ts",

@@ -7,0 +8,0 @@ "scripts": {

@@ -712,3 +712,3 @@ 'use strict'

const fastify = Fastify()
fastify.register(cors, { origin: /(example|other)\.com/gi })
fastify.register(cors, { origin: /(?:example|other)\.com/giu })

@@ -715,0 +715,0 @@ fastify.get('/', (req, reply) => {

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

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

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

@@ -100,3 +100,3 @@ import fastify, { FastifyRequest } from 'fastify'

const corsDelegate: OriginFunction = (origin, cb) => {
if (typeof origin === 'undefined' || /localhost/.test(origin)) {
if (origin === undefined || /localhost/.test(origin)) {
cb(null, true)

@@ -121,2 +121,14 @@ return

app.register(fastifyCors, {
origin: (origin, cb) => cb(null, true)
})
app.register(fastifyCors, {
origin: (origin, cb) => cb(null, '*')
})
app.register(fastifyCors, {
origin: (origin, cb) => cb(null, /\*/)
})
const appHttp2 = fastify({ http2: true })

@@ -212,3 +224,3 @@

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

@@ -215,0 +227,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