mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-03 17:43:54 +01:00
10 lines
436 B
TypeScript
10 lines
436 B
TypeScript
import { RequestHandler } from "express";
|
|
|
|
/** The asterisk request target asks about the server, not a session or route. */
|
|
export const serverOptions: RequestHandler = (req, res, next) => {
|
|
if (req.originalUrl !== "*") return next();
|
|
if (req.method !== "OPTIONS") { res.status(400).json({ error: "invalid_request" }); return; }
|
|
res.setHeader("Allow", "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS");
|
|
res.status(204).end();
|
|
};
|