cors icon indicating copy to clipboard operation
cors copied to clipboard

Use cors on static files only?

Open vedantroy opened this issue 2 years ago • 1 comments

I have the following line in my code:

app.use(express.static("public", { maxAge: "1h" }));

Ideally, I'd only allow cors on this route. What would be a good way to do that?

vedantroy avatar Jun 04 '22 04:06 vedantroy

As per the express documentation:

app.use([path,] callback [, callback...])

app.use(cors(options), express.static("public", { maxAge: "1h" }));

dorward avatar Feb 22 '24 14:02 dorward