mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
add cors + adjusting dockerfile
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
|
||||
import { checkApiKey, checkAuthorization, eventsListApi } from '~/server/services/ApiService';
|
||||
import { useCors } from '~/server/utils/useCors';
|
||||
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
useCors(event);
|
||||
|
||||
const { rows, from, to, limit } = await readBody(event);
|
||||
|
||||
const token = checkAuthorization(event);
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
|
||||
import { checkApiKey, checkAuthorization, eventsListApi, } from '~/server/services/ApiService';
|
||||
import { useCors } from '~/server/utils/useCors';
|
||||
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
useCors(event);
|
||||
|
||||
const { row, from, to, limit } = getQuery(event);
|
||||
|
||||
const token = checkAuthorization(event);
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
|
||||
import { checkApiKey, checkAuthorization } from '~/server/services/ApiService';
|
||||
import { visitsListApi } from '../../services/ApiService';
|
||||
import { useCors } from '~/server/utils/useCors';
|
||||
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
useCors(event);
|
||||
|
||||
const { rows, from, to, limit } = await readBody(event);
|
||||
|
||||
const token = checkAuthorization(event);
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
import { ApiSettingsModel } from '@schema/ApiSettingsSchema';
|
||||
import { VisitModel } from '@schema/metrics/VisitSchema';
|
||||
import { checkApiKey, checkAuthorization, visitsListApi } from '~/server/services/ApiService';
|
||||
import { useCors } from '~/server/utils/useCors';
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
useCors(event);
|
||||
|
||||
const { row, from, to, limit } = getQuery(event);
|
||||
|
||||
const token = checkAuthorization(event);
|
||||
|
||||
10
dashboard/server/utils/useCors.ts
Normal file
10
dashboard/server/utils/useCors.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
import type { H3Event, EventHandlerRequest } from 'h3';
|
||||
|
||||
|
||||
export function useCors(event: H3Event<EventHandlerRequest>) {
|
||||
setResponseHeader(event, 'Access-Control-Allow-Origin', '*');
|
||||
setResponseHeader(event, 'Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE');
|
||||
setResponseHeader(event, 'Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
||||
}
|
||||
Reference in New Issue
Block a user