Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
@elysiajs/cors
Advanced tools
Plugin for elysia that for Cross Origin Requests (CORs)
bun add @elysiajs/cors
import { Elysia } from 'elysia'
import { cors } from '@elysiajs/cors'
const app = new Elysia()
.use(cors())
.listen(8080)
@default true
Assign the Access-Control-Allow-Origin header.
Value can be one of the following:
string
- String of origin which will directly assign to Access-Control-Allow-Origin
boolean
- If set to true, Access-Control-Allow-Origin
will be set to *
(accept all origin)
RegExp
- Pattern to use to test with request's url, will accept origin if matched.
Function
- Custom logic to validate origin acceptance or not. will accept origin if true
is returned.
Context
just like Handler
// Example usage
app.use(cors, {
origin: ({ request, headers }) => true
})
// Type Definition
type CORSOriginFn = (context: Context) => boolean | void
Array<string | RegExp | Function>
- Will try to find truthy value of all options above. Will accept Request if one is true
.
@default *
Assign Access-Control-Allow-Methods header.
Value can be one of the following: Accept:
undefined | null | ''
- Ignore all methods.
*
- Accept all methods.
HTTPMethod
- Will be directly set to Access-Control-Allow-Methods.
HTTPMethod[]
- Allow multiple HTTP methods.
@default *
Assign Access-Control-Allow-Headers header.
Allow incoming request with the specified headers.
Value can be one of the following:
string
string[]
- Allow multiple HTTP methods.
@default *
Assign Access-Control-Exposed-Headers header.
Return the specified headers to request in CORS mode.
Value can be one of the following:
string
string[]
- Allow multiple HTTP methods.
@default true
Assign Access-Control-Allow-Credentials header.
Allow incoming requests to send credentials
header.
boolean
- Available if set to true
.@default 5
Assign Access-Control-Max-Age header.
Allow incoming requests to send credentials
header.
number
- Duration in seconds to indicates how long the results of a preflight request can be cached.@default true
Add [OPTIONS] /*
handler to handle preflight request which response with HTTP 204
and CORS hints.
boolean
- Available if set to true
.FAQs
Plugin for Elysia that for Cross Origin Requests (CORs)
The npm package @elysiajs/cors receives a total of 11,582 weekly downloads. As such, @elysiajs/cors popularity was classified as popular.
We found that @elysiajs/cors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.