Skip to content

Commit

Permalink
feat: update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
coratgerl committed Jul 28, 2024
1 parent 54fa94d commit 118e386
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/wobe-documentation/doc/concepts/route.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,19 @@ const app = new Wobe()
)
.listen(3000)
```

## Prelight requests

You can enable prelight requests for cors like this :

```ts
const app = new Wobe().options(
'*',
(ctx) => ctx.res.send(null),
cors({
origin: 'http://localhost:3000',
allowHeaders: ['content-type'],
credentials: true,
}),
)
```
18 changes: 17 additions & 1 deletion packages/wobe-documentation/doc/ecosystem/hooks/cors.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,23 @@ Wobe has a `beforeHandker` hook to manage CORS.

## Example

You can only authorize some requests with the `origin` option.
You can only authorize some requests with the `origin` option

First of all you will need to enable prelight requests for cors like this :

```ts
const app = new Wobe().options(
'*',
(ctx) => ctx.res.send(null),
cors({
origin: 'http://localhost:3000',
allowHeaders: ['content-type'],
credentials: true,
}),
)
```

than:

```ts
import { Wobe, cors } from 'wobe'
Expand Down

0 comments on commit 118e386

Please sign in to comment.