allow same-origin requests without explicit origin header
This commit is contained in:
@@ -86,9 +86,9 @@ export async function createServer() {
|
|||||||
app.addHook("onRequest", async (req, reply) => {
|
app.addHook("onRequest", async (req, reply) => {
|
||||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(req.method)) {
|
if (["POST", "PUT", "PATCH", "DELETE"].includes(req.method)) {
|
||||||
const origin = req.headers.origin;
|
const origin = req.headers.origin;
|
||||||
// Server-to-server webhook calls don't send Origin headers
|
// no Origin header = same-origin request or server-to-server call
|
||||||
if (!origin && req.url.startsWith('/api/v1/plugins/') && req.url.includes('/webhook')) return;
|
if (!origin) return;
|
||||||
if (!origin || !allowedOrigins.has(origin)) {
|
if (!allowedOrigins.has(origin)) {
|
||||||
return reply.status(403).send({ error: "Forbidden" });
|
return reply.status(403).send({ error: "Forbidden" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user