feat: setup spa proxy when develop backend server

This commit is contained in:
SikongJueluo 2025-05-12 21:08:08 +08:00
parent 257d63e63d
commit 9eb3acb94c
No known key found for this signature in database
4 changed files with 6 additions and 5 deletions

View File

@ -4,7 +4,7 @@
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite --host",
"build": "run-p type-check \"build-only {@}\" --", "build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview", "preview": "vite preview",
"build-only": "vite build", "build-only": "vite build",

View File

@ -106,11 +106,9 @@ try
app.UseCors(); app.UseCors();
app.UseAuthorization(); app.UseAuthorization();
// if (app.Environment.IsDevelopment()) // Swagger
// {
app.UseOpenApi(); app.UseOpenApi();
app.UseSwaggerUi(); app.UseSwaggerUi();
// }
// Router // Router
app.MapControllers(); app.MapControllers();

View File

@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="PublishAllRids.xml" /> <Import Project="PublishAllRids.xml" />
<!-- <Import Project="PublishSPA.xml" /> -->
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>

View File

@ -39,5 +39,9 @@ export default defineConfig({
build: { build: {
outDir: 'wwwroot', outDir: 'wwwroot',
emptyOutDir: true, // also necessary emptyOutDir: true, // also necessary
},
server: {
proxy: {},
port: 5173,
} }
}) })