More styling for linter, more better code
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
|
||||
import { defineConfig } from 'vite';
|
||||
import { defineConfig, type ProxyOptions } from 'vite';
|
||||
import plugin from '@vitejs/plugin-react';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
@ -16,11 +16,13 @@ const certificateName = "usentrycoach.client";
|
||||
const certFilePath = path.join(baseFolder, `${certificateName}.pem`);
|
||||
const keyFilePath = path.join(baseFolder, `${certificateName}.key`);
|
||||
|
||||
if (!fs.existsSync(baseFolder)) {
|
||||
if (!fs.existsSync(baseFolder))
|
||||
{
|
||||
fs.mkdirSync(baseFolder, { recursive: true });
|
||||
}
|
||||
|
||||
if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) {
|
||||
if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath))
|
||||
{
|
||||
if (0 !== child_process.spawnSync('dotnet', [
|
||||
'dev-certs',
|
||||
'https',
|
||||
@ -29,7 +31,8 @@ if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) {
|
||||
'--format',
|
||||
'Pem',
|
||||
'--no-password',
|
||||
], { stdio: 'inherit', }).status) {
|
||||
], { stdio: 'inherit', }).status)
|
||||
{
|
||||
throw new Error("Could not create certificate.");
|
||||
}
|
||||
}
|
||||
@ -37,6 +40,23 @@ if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) {
|
||||
const target = env.ASPNETCORE_HTTPS_PORT ? `https://localhost:${env.ASPNETCORE_HTTPS_PORT}` :
|
||||
env.ASPNETCORE_URLS ? env.ASPNETCORE_URLS.split(';')[0] : 'https://localhost:7085';
|
||||
|
||||
// Define a list of all existing backend routes.
|
||||
const backendRoutes = ['/login', '/ephemeral_token'];
|
||||
|
||||
// For development, we have a node.js server running that delivers our frontend.
|
||||
// We have to configure proxies for the backend calls, so that node.js will forward them to the backend.
|
||||
const proxyConfig = backendRoutes.reduce((acc, path) =>
|
||||
{
|
||||
acc[path] = {
|
||||
target: target,
|
||||
// disable certificate verification because the development certificate is self-signed
|
||||
secure: false,
|
||||
changeOrigin: true
|
||||
}
|
||||
return acc;
|
||||
}, {} as Record<string, ProxyOptions>);
|
||||
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [plugin()],
|
||||
@ -46,13 +66,8 @@ export default defineConfig({
|
||||
}
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'^/ephemeral_token': {
|
||||
target,
|
||||
secure: false
|
||||
}
|
||||
},
|
||||
port: parseInt(env.DEV_SERVER_PORT || '54044'),
|
||||
proxy: proxyConfig,
|
||||
port: parseInt(env.DEV_SERVER_PORT ?? '54044'),
|
||||
https: {
|
||||
key: fs.readFileSync(keyFilePath),
|
||||
cert: fs.readFileSync(certFilePath),
|
||||
|
||||
Reference in New Issue
Block a user