Skip to content

Commit 6863460

Browse files
committed
fix: Add support for OPTIONS request to support fetch
1 parent 0a8eb8c commit 6863460

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/micro-analytics-cli/src/handler.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ async function analyticsHandler(req, res) {
5353
if (pathname.length <= 1) {
5454
throw createError(400, 'Please include a path to a page.');
5555
}
56+
if (req.method === 'OPTIONS') {
57+
res.setHeader('Access-Control-Allow-Headers', 'content-type');
58+
return send(res, 204);
59+
}
5660
if (req.method !== 'GET' && req.method !== 'POST') {
5761
throw createError(400, 'Please make a GET or a POST request.');
5862
}

0 commit comments

Comments
 (0)