import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
    plugins: [vue()],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    server: {
        host: true,
        cors: true,
        headers: {
            //allow all origins
            'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
            'Access-Control-Allow-Headers': 'Origin, Content-Type, X-Auth-Token, Authorization, Accept, charset, boundary, Content-Length',
            'Access-Control-Allow-Credentials': 'true',
            'Access-Control-Max-Age': '86400',
            //'Upgrade-Insecure-Requests': '1',
            'Content-Security-Policy': 'default-src \'self\';'
                + ' script-src \'self\' \'wasm-unsafe-eval\' \'unsafe-eval\';'
                + ' style-src \'self\' \'unsafe-inline\';'
                + ' img-src \'self\' * data:;'
                + ' connect-src * data:',
        },
    },
    test: {
        include: ['src/tests/**/*.js'],
        globals: true,
        environment: "jsdom"
    }
})
