https://github.com/curveball/cors
CORS plugin middleware for Curveball
https://github.com/curveball/cors
cors curveball hacktoberfest http middleware
Last synced: 6 months ago
JSON representation
CORS plugin middleware for Curveball
- Host: GitHub
- URL: https://github.com/curveball/cors
- Owner: curveball
- License: mit
- Created: 2020-03-13T18:38:20.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-01-20T06:50:38.000Z (about 2 years ago)
- Last Synced: 2025-08-22T00:51:14.075Z (7 months ago)
- Topics: cors, curveball, hacktoberfest, http, middleware
- Language: TypeScript
- Homepage:
- Size: 733 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Curveball CORS middleware
=====================
This package is a middleware for the [Curveball][1] framework.
Installation
------------
npm install @curveball/cors
Getting started
---------------
After installing the NPM package, simply import the CORS middleware to an existing Curveball server:
```typescript
import cors from '@curveball/cors';
import { Application } from '@curveball/core';
const app = new Application();
app.use(cors());
```
When manually providing CORS options, this is how it should look:
```typescript
app.use(cors({
allowOrigin: '*',
allowHeaders: ['Content-Type', 'Accept'],
allowMethods: ['GET', 'POST'],
exposeHeaders: ['Link', 'Date'],
credentials: true
}));
```
If no options are given, it will use these defaults:
```typescript
{
allowOrigin: '*',
allowHeaders: ['Content-Type', 'User-Agent', 'Authorization', 'Accept', 'Prefer', 'Prefer-Push', 'Link'],
allowMethods: ['DELETE', 'GET', 'PATCH', 'POST', 'PUT'],
exposeHeaders: ['Location', 'Link'],
credentials: false
}
```
[1]: https://github.com/curveball/