Skip to content

Commit 1236aa5

Browse files
committed
fix: configure Vite proxy and ASP.NET static file serving for SPA
- Fix Vite dev server proxy to target http://localhost:5000 (was https://localhost:5001) - Set explicit Vite dev server port to 3000 with strictPort - Add UseDefaultFiles/UseStaticFiles/MapFallbackToFile for serving the React SPA from wwwroot in production - Move Swagger UI off root route so index.html is served at / - Update CORS origin to match Vite dev server port - Add SQLite database files to .gitignore Made-with: Cursor
1 parent 28fa85c commit 1236aa5

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ app_settings_backup.config
298298
# Consul local cache
299299
/**/consul-config.json
300300

301+
# SQLite databases
302+
*.db
303+
*.db-shm
304+
*.db-wal
305+
301306
# Playwright
302307
**/test-results/
303308
**/playwright-report/

‎src/Agoda.DevExTelemetry.WebApi/Program.cs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
{
4747
options.AddDefaultPolicy(policy =>
4848
{
49-
policy.WithOrigins("http://localhost:5173")
49+
policy.WithOrigins("http://localhost:3000")
5050
.AllowAnyHeader()
5151
.AllowAnyMethod();
5252
});
@@ -90,12 +90,17 @@
9090
app.UseCors();
9191
app.UseSerilogRequestLogging();
9292
app.UseRouting();
93+
94+
app.UseDefaultFiles();
95+
app.UseStaticFiles();
96+
9397
app.MapControllers();
9498
app.UseSwagger();
9599
app.UseSwaggerUI(c =>
96100
{
97101
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Agoda.DevExTelemetry");
98-
c.RoutePrefix = string.Empty;
99102
});
100103

104+
app.MapFallbackToFile("index.html");
105+
101106
app.Run();

‎src/Clientside/vite.config.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ export default defineConfig({
1010
},
1111
},
1212
server: {
13+
port: 3000,
14+
host: 'localhost',
15+
strictPort: true,
1316
proxy: {
1417
'/api': {
15-
target: 'https://localhost:5001',
18+
target: 'http://localhost:5000',
1619
changeOrigin: true,
1720
secure: false,
1821
},

0 commit comments

Comments
 (0)