Refactor CORS headers to allow all origins and additional headers

This commit is contained in:
Simon Larsen 2024-07-09 20:08:45 +01:00
parent 0c7db14e99
commit 3234112644
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
3 changed files with 8 additions and 4 deletions

View File

@ -61,11 +61,11 @@ const setDefaultHeaders: RequestHandler = (
}
res.header("Access-Control-Allow-Credentials", "true");
res.header("Access-Control-Allow-Origin", req.headers["origin"]);
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS");
res.header(
"Access-Control-Allow-Headers",
"X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept,Authorization",
"X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept, Authorization, DNT, X-CustomHeader, Keep-Alive, User-Agent, If-Modified-Since, Cache-Control, Content-Type",
);
next();

View File

@ -33,7 +33,9 @@ export default class Telemetry {
provider.addSpanProcessor(
new BatchSpanProcessor(
new OTLPTraceExporter({
url: URL.fromString(OpenTelemetryExporterOtlpEndpoint?.toString() + "/v1/traces").toString(),
url: URL.fromString(
OpenTelemetryExporterOtlpEndpoint?.toString() + "/v1/traces",
).toString(),
headers: OpenTelemetryExporterOtlpHeaders,
}),
),

View File

@ -62,7 +62,9 @@ export default class TelemetryIngest {
});
if (!service) {
throw new BadRequestException("Invalid service token: "+serviceTokenInHeader);
throw new BadRequestException(
"Invalid service token: " + serviceTokenInHeader,
);
}
(req as TelemetryRequest).serviceId = service.id as ObjectID;