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

@types/cors

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/cors

TypeScript definitions for cors

  • 2.8.17
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.4M
decreased by-14.19%
Maintainers
1
Weekly downloads
 
Created

What is @types/cors?

The @types/cors package provides TypeScript type definitions for the cors middleware used in Express/Connect applications. It allows TypeScript developers to use cors in their projects with the benefits of type checking and IntelliSense in their IDE. This package does not contain functionality by itself but offers type definitions to enhance development experience when using the cors package.

What are @types/cors's main functionalities?

CORS Configuration

This code sample demonstrates how to configure CORS policy for an Express application. It specifies that only requests from 'http://example.com' are allowed and sets a successful status code for preflight requests.

{ "origin": "http://example.com", "optionsSuccessStatus": 200 }

Enabling CORS for a Single Route

This example shows how to enable CORS for a specific route in an Express application. It uses the cors middleware directly in the route definition.

app.get('/products/:id', cors(), function (req, res, next) { res.json({msg: 'This is CORS-enabled for a Single Route'}); })

Other packages similar to @types/cors

FAQs

Package last updated on 20 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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