chore(dev): add HTTPS Vite dev server and HTTP launch profile
Serve Vite over HTTPS on :7081 using a certificate exported from dotnet dev-certs (scripts/dev-certs.ps1). Add an http launch profile on :5078 as the default backend and point the /api proxy at it, so dev runs on defaults without env vars.
This commit is contained in:
@@ -12,6 +12,9 @@ dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Lokalne certyfikaty dev (scripts/dev-certs.ps1)
|
||||
.certs/
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"certs": "pwsh ../scripts/dev-certs.ps1",
|
||||
"build": "vue-tsc -b && vite build",
|
||||
"preview": "vite preview",
|
||||
"copy": "node ../scripts/copy-client.mjs",
|
||||
|
||||
+20
-1
@@ -1,11 +1,30 @@
|
||||
import fs from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
// Certyfikat PEM wygenerowany przez scripts/dev-certs.ps1 (dotnet dev-certs https).
|
||||
const certDir = fileURLToPath(new URL('./.certs', import.meta.url))
|
||||
const certFile = `${certDir}/dev.pem`
|
||||
const keyFile = `${certDir}/dev-key.pem`
|
||||
const hasCerts = fs.existsSync(certFile) && fs.existsSync(keyFile)
|
||||
|
||||
if (!hasCerts) {
|
||||
console.warn(
|
||||
'[vite] Brak certyfikatów w client/.certs — dev-server wstanie po HTTP. ' +
|
||||
'Uruchom: pwsh ../scripts/dev-certs.ps1 (z katalogu client/).',
|
||||
)
|
||||
}
|
||||
|
||||
// Domyślnie backend z profilu `http` (launchSettings.json), port 5078.
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
server: {
|
||||
port: 5173,
|
||||
port: 7081,
|
||||
https: hasCerts
|
||||
? { cert: fs.readFileSync(certFile), key: fs.readFileSync(keyFile) }
|
||||
: undefined,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:5078',
|
||||
|
||||
Reference in New Issue
Block a user