Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@nozomuikuta/h3-cors
Advanced tools
Changelog
v0.2.2
Readme
h3-native CORS event handler
This package has been integrated to h3
v1.5.0, so you can import all features of this package from h3
directly. 🎉
This repository and the npm package has been archived.
Thank you for all kinds of contribution to this package!
Install package:
# npm
npm install @nozomuikuta/h3-cors
# yarn
yarn add @nozomuikuta/h3-cors
# pnpm
pnpm install @nozomuikuta/h3-cors
Import:
// ESM
import { defineCorsEventHandler } from '@nozomuikuta/h3-cors'
// CommonJS
const { defineCorsEventHandler } = require('@nozomuikuta/h3-cors')
Usage:
import { createServer } from 'http'
import { createApp } from 'h3'
import { defineCorsEventHandler } from '@nozomuikuta/h3-cors'
const app = createApp()
app.use(defineCorsEventHandler({ /* options */ }))
app.use('/', () => 'Hello world!')
createServer(app).listen(process.env.PORT || 3000)
origin
is either of the following values to configure Access-Control-Allow-Origin CORS header
"*"
(default)"null"
false
is returned, an error is thrownmethods
is "*"
or an array of HTTP methods to configures Access-Control-Allow-Methods CORS header (default: "*"
)allowHeaders
is "*"
or an array of HTTP headers to configure Access-Control-Allow-Headers CORS header (default: "*"
)exposeHeaders
is "*"
or an array of HTTP headers to configure Access-Control-Expose-Headers CORS header (default: "*"
)credentials
is boolean to configure Access-Control-Allow-Credentials CORS header (default: false
)maxAge
is a string to configure Access-Control-Max-Age, or false
to unset the header (default: false
)preflight.statusCode
is used to set event.res.statusCode
for preflight request (default: 204
)interface CorsOptions {
origin?: '*' | 'null' | (string | RegExp)[] | ((origin: string) => boolean)
methods?: '*' | HTTPMethod[]
allowHeaders?: '*' | string[]
exposeHeaders?: '*' | string[]
credentials?: boolean
maxAge?: string | false
preflight?: {
statusCode?: number
}
}
You can import utility functions as well as event handler.
isPreflight(event)
isAllowedOrigin(origin, options)
appendCorsPreflightHeaders(event, options)
appendCorsActualRequestHeaders(event, options)
corepack enable
pnpm install
pnpm dev
Made with 💛
Published under MIT License.
FAQs
h3-native CORS event handler
The npm package @nozomuikuta/h3-cors receives a total of 515 weekly downloads. As such, @nozomuikuta/h3-cors popularity was classified as not popular.
We found that @nozomuikuta/h3-cors demonstrated a not healthy version release cadence and project activity because the last version was released 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.