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

@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.1 to 8.4.2

2

index.js

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

// This route simply enables fastify to accept preflight requests.
fastify.options('*', { schema: { hide: hideOptionsRoute } }, (req, reply) => {
fastify.options('/*', { schema: { hide: hideOptionsRoute } }, (req, reply) => {
if (!req.corsPreflightEnabled) {

@@ -78,0 +78,0 @@ // Do not handle preflight requests if the origin option disabled CORS

{
"name": "@fastify/cors",
"version": "8.4.1",
"version": "8.4.2",
"description": "Fastify CORS",

@@ -41,3 +41,3 @@ "main": "index.js",

"standard": "^17.0.0",
"tap": "^16.0.0",
"tap": "16.3.9",
"tsd": "^0.29.0",

@@ -44,0 +44,0 @@ "typescript": "^5.0.2"

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

const fastify = Fastify()
fastify.register(cors, () => (a, b, c) => {})
fastify.register(cors, () => (a, b, c) => { })

@@ -946,1 +946,34 @@ fastify.get('/', (req, reply) => {

})
test('should support embedded cors registration with route params', t => {
t.plan(3)
const fastify = Fastify()
const custom = async (instance, opts) => {
instance.register(cors, {
origin: ['example.com']
})
instance.get('/route1', (req, reply) => {
reply.send('ok')
})
}
fastify.register(custom, {
prefix: '/:id'
})
fastify.inject({
method: 'OPTIONS',
url: '/id1/route1',
headers: {
'access-control-request-method': 'GET',
origin: 'example.com'
}
}, (err, res) => {
t.error(err)
t.equal(res.statusCode, 204)
t.equal(res.headers['access-control-allow-origin'], 'example.com')
})
})

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

fastify.addHook('onRoute', (route) => {
if (route.method === 'OPTIONS' && route.url === '*') {
if (route.method === 'OPTIONS' && route.url === '/*') {
t.equal(route.schema.hide, true)

@@ -210,3 +210,3 @@ }

fastify.addHook('onRoute', (route) => {
if (route.method === 'OPTIONS' && route.url === '*') {
if (route.method === 'OPTIONS' && route.url === '/*') {
t.equal(route.schema.hide, false)

@@ -213,0 +213,0 @@ }

Sorry, the diff of this file is not supported yet

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