Skip to content

Commit

Permalink
🔧 fix: mirror preflight allow method
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyAom committed Jul 9, 2024
1 parent 6ba3b48 commit 010f999
Show file tree
Hide file tree
Showing 9 changed files with 407 additions and 452 deletions.
24 changes: 0 additions & 24 deletions .cjs.swcrc

This file was deleted.

24 changes: 0 additions & 24 deletions .es.swcrc

This file was deleted.

7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"useTabs": true,
"tabWidth": 4,
"semi": false,
"singleQuote": true,
"trailingComma": "none"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.0.4 - 9 Jul 2024
Bug fix:
- Mirror allow method on preflight options

# 1.0.3 - 18 Mar 2024
Feature:
- add `true` to allowHeaders, and exposeHeaders
Expand Down
Binary file modified bun.lockb
Binary file not shown.
56 changes: 16 additions & 40 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,28 @@
import { Elysia, t } from 'elysia'
import { cors } from '../src/index'

const app = new Elysia({
forceErrorEncapsulation: true,
precompile: true
})
const app = new Elysia()
.use(
cors({
origin: 'http://saltyaom.com',
origin: 'http://localhost:3001',
credentials: true
})
)
.get('/', () => 'A')
.onError(({ error, code }) => {
if(code === "NOT_FOUND") return "A"

console.log(error)
})
.post('/', ({ body, cookie: { session } }) => {
session!.value = 'hi'

return body
}, {
type: "multipart/form-data",
body: t.Object({
a: t.File({
type: "image"
})
}),
async parse({}, contentType) {
console.log(contentType)
}
})
.compile()
.put('/', () => 'ok')
.listen(3000)

// console.log(app.routes[1]?.composed.toString())

// console.log(`Elysia is running at ${app.server?.hostname}:${app.server?.port}`)
new Elysia()
.get('/', () => 'hi')
.listen(3001)

app.handle(
new Request('http://localhost/awd', {
headers: {
origin: 'https://saltyaom.com'
}
})
)
.then((x) => x.headers.toJSON())
.then(console.log)
// app.handle(
// new Request('http://localhost/awd', {
// headers: {
// origin: 'https://saltyaom.com'
// }
// })
// )
// .then((x) => x.headers.toJSON())
// .then(console.log)

export type App = typeof app
// export type App = typeof app
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elysiajs/cors",
"version": "1.0.3",
"version": "1.0.4",
"description": "Plugin for Elysia that for Cross Origin Requests (CORs)",
"author": {
"name": "saltyAom",
Expand Down Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@types/bun": "^1.0.4",
"@types/node": "^18.11.7",
"elysia": "1.0.16",
"elysia": "1.0.28",
"eslint": "^8.26.0",
"rimraf": "^3.0.2",
"typescript": "^5.4.3"
Expand Down
Loading

0 comments on commit 010f999

Please sign in to comment.