mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-07-01 00:51:36 +00:00
Set missing CORS headers for Report API responses. (#222)
This commit is contained in:
parent
e49e4d05eb
commit
097829d75a
|
@ -52,8 +52,20 @@ export class WebAPIs {
|
||||||
// Configure /report API.
|
// Configure /report API.
|
||||||
if (config.web.abuseReporting.enabled) {
|
if (config.web.abuseReporting.enabled) {
|
||||||
console.log(`Configuring ${API_PREFIX}/report/:room_id/:event_id...`);
|
console.log(`Configuring ${API_PREFIX}/report/:room_id/:event_id...`);
|
||||||
|
this.webController.options(`${API_PREFIX}/report/:room_id/:event_id`, async (request, response) => {
|
||||||
|
// reply with CORS options
|
||||||
|
response.header("Access-Control-Allow-Origin", "*");
|
||||||
|
response.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Authorization, Date");
|
||||||
|
response.header("Access-Control-Allow-Methods", "POST, OPTIONS");
|
||||||
|
response.status(200);
|
||||||
|
return response.send();
|
||||||
|
});
|
||||||
this.webController.post(`${API_PREFIX}/report/:room_id/:event_id`, async (request, response) => {
|
this.webController.post(`${API_PREFIX}/report/:room_id/:event_id`, async (request, response) => {
|
||||||
console.debug(`Received a message on ${API_PREFIX}/report/:room_id/:event_id`, request.params);
|
console.debug(`Received a message on ${API_PREFIX}/report/:room_id/:event_id`, request.params);
|
||||||
|
// set CORS headers for the response
|
||||||
|
response.header("Access-Control-Allow-Origin", "*");
|
||||||
|
response.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Authorization, Date");
|
||||||
|
response.header("Access-Control-Allow-Methods", "POST, OPTIONS");
|
||||||
await this.handleReport({ request, response, roomId: request.params.room_id, eventId: request.params.event_id })
|
await this.handleReport({ request, response, roomId: request.params.room_id, eventId: request.params.event_id })
|
||||||
});
|
});
|
||||||
console.log(`Configuring ${API_PREFIX}/report/:room_id/:event_id... DONE`);
|
console.log(`Configuring ${API_PREFIX}/report/:room_id/:event_id... DONE`);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user