Added CORS to website API endpoints.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { getPageviewMetrics, getSessionMetrics, getWebsiteById } from 'lib/queries';
|
||||
import { ok, methodNotAllowed, unauthorized, badRequest } from 'lib/response';
|
||||
import { allowQuery } from 'lib/auth';
|
||||
import { useCors } from 'lib/middleware';
|
||||
|
||||
const sessionColumns = ['browser', 'os', 'device', 'country', 'language'];
|
||||
const pageviewColumns = ['url', 'referrer'];
|
||||
@@ -26,6 +27,8 @@ function getColumn(type) {
|
||||
|
||||
export default async (req, res) => {
|
||||
if (req.method === 'GET') {
|
||||
await useCors(req, res);
|
||||
|
||||
if (!(await allowQuery(req))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user