I am trying to build a Rest API using Alephjs & Alephjs file based routing is Great, but When I am trying to set CORS headers for all routes, I can't do it using a middleware.
I am try to do it like these:
import { serve } from "aleph/server";
import routes from "./routes/_export.ts";
import cors from "https://deno.land/x/edge_cors@0.2.1/src/cors.ts";
serve({
router: { routes },
middlewares: [
{
name: "cors-middleware",
async fetch(request, { next }) {
// next() will invoke a respective route function
const response = await next();
return cors(request, response);
},
},
],
});
I think there should be a way of getting a route response within a middleware?
I am trying to build a Rest API using Alephjs & Alephjs file based routing is Great, but When I am trying to set CORS headers for all routes, I can't do it using a middleware.
I am try to do it like these:
I think there should be a way of getting a route response within a middleware?
Thanks.