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

@tinyhttp/cors

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/cors

tinyhttp CORS module

  • 0.1.21
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
40K
decreased by-15.9%
Maintainers
1
Weekly downloads
 
Created
Source

@tinyhttp/cors

tinyhttp CORS module

Installation

npm install @tinyhttp/cors

API

import { cors } from '@tinyhttp/cors'

Options

host

Host that is allowed to send cross-origin requests. Defaults to '*'.

methods

Allowed methods for performing a cross-origin request. Default ones are ['GET', 'POST', 'PUT', 'PATCH', 'HEAD'] and can be accessed with defaultMethods:

import { App } from '@tinyhttp/app'
import { defaultMethods, cors } from '@tinyhttp/cors'

const app = new App()

app.use(
  cors({
    methods: defaultMethods.filter(m => m !== 'DELETE'),
    host: 'https://example.com'
  })
)
headers

Allowed HTTP headers that can be sent in a cross-origin request. Default ones are ['Origin', 'X-Requested-With', 'Content-Type'] and can be accessed with defaultHeaders:

import { App } from '@tinyhttp/app'
import { defaultHeaders, cors } from '@tinyhttp/cors'

const app = new App()

app.use(
  cors({
    methods: [...defaultHeaders, 'X-Custom-Header'],
    host: 'https://example.com'
  })
)

Example

import { App } from '@tinyhttp/app'
import { cors } from '@tinyhttp/cors'

const app = new App()

app
  .use(
    cors({
      host: 'https://example.com'
    })
  )
  .get('/', (_, res) => void res.end('Hello World'))

License

MIT

Keywords

FAQs

Package last updated on 20 Jun 2020

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