Skip to content

CORS behavior not aligning with documentation #59

@ArkenV

Description

@ArkenV

What version of Elysia is running?

Bun: 1.0.18, Elysia: Elysia --revision fails but it's a fresh installation as of 12/12/2024

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

import { Elysia } from "elysia";
import { cors } from "@elysiajs/cors";

const app = new Elysia()
  .use(cors({ origin: 'localhost:4200' }))
  .post("/test", req => req.body)
  .listen(3000);

What is the expected behavior?

I expected only requests coming from localhost:4200 to be allowed.

What do you see instead?

For some reason, the origin must be passed in as an array. ['localhost:4200'] works, but the other types (regex, true) listed in the documentation do not. I understand true would allow all traffic and wouldn't be suitable for this purpose anyway, but I just want to point out that this also isn't functioning.

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

It was a brand new project specifically for illustrating this bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions