score:6

Accepted answer

solution in my case was pretty easy.

i had to import oakcors into my deno api app.ts

import { oakcors } from "https://deno.land/x/cors/mod.ts";

after that, just add the excluded origin after app instantiation:

app.use(
    oakcors({
      origin: "http://localhost:3000"
    }),
);

note: i tried to set origin to origin: false and that did not work in my case.

for more options on deno cors here is a link: https://deno.land/x/cors

score:-3

placeapp.use(oakcors()) before your routes like this:

app.use(oakcors())
app.use(route.routes())

this is allow all cors before to manage the routes

score:2

for me, i had to first pass oakcors configuration to the app and then the routes.

app.use(oakcors({
    origin: 'http://localhost:4200',
    optionssuccessstatus: 200,
}));
app.use(router.routes());

score:2

this works just fine:

app.use(oakcors({ origin: "*" }));

Related Query

More Query from same tag