Compare commits

...

5 Commits

Author SHA1 Message Date
steinhelge 0dba448f15 refactor: name CORS policy 'AllowFrontend'
Build & Push Hospitality / build-and-push (push) Failing after 2m57s
2025-11-26 12:43:45 +01:00
steinhelge 072935e133 config: Update API service connection string and add Traefik load balancer port configuration. 2025-11-26 12:41:59 +01:00
steinhelge c3750239c7 feat: configure Traefik load balancer for hospitality-dev-api to use port 8080
Build & Push Hospitality / build-and-push (push) Failing after 3m8s
2025-11-26 12:33:18 +01:00
steinhelge d1568c788a config: Allow all origins in CORS policy and disable HTTPS redirection.
Build & Push Hospitality / build-and-push (push) Failing after 2m4s
2025-11-26 12:07:31 +01:00
steinhelge dcc8e10bd2 config: Expand CORS policy to include development and production frontend URLs.
Build & Push Hospitality / build-and-push (push) Successful in 3m5s
2025-11-26 11:48:38 +01:00
3 changed files with 9 additions and 9 deletions
+2 -4
View File
@@ -64,14 +64,12 @@ builder.Services.AddScoped<ITransactionService, TransactionService>();
// Add CORS // Add CORS
builder.Services.AddCors(options => builder.Services.AddCors(options =>
{
options.AddPolicy("AllowFrontend", policy => options.AddPolicy("AllowFrontend", policy =>
{ {
policy.WithOrigins("http://localhost:5173") policy.SetIsOriginAllowed(origin => true) // Allow any origin
.AllowAnyHeader() .AllowAnyHeader()
.AllowAnyMethod(); .AllowAnyMethod();
}); });
});
var app = builder.Build(); var app = builder.Build();
@@ -97,7 +95,7 @@ if (app.Environment.IsDevelopment())
app.UseSwaggerUI(); app.UseSwaggerUI();
} }
app.UseHttpsRedirection(); // app.UseHttpsRedirection(); // Disabled because Traefik handles SSL
app.UseCors("AllowFrontend"); app.UseCors("AllowFrontend");
@@ -39,6 +39,7 @@ services:
- "traefik.http.routers.hospitality-dev-api.rule=Host(`hospitality-dev-api.theriise.net`)" - "traefik.http.routers.hospitality-dev-api.rule=Host(`hospitality-dev-api.theriise.net`)"
- "traefik.http.routers.hospitality-dev-api.entrypoints=websecure" - "traefik.http.routers.hospitality-dev-api.entrypoints=websecure"
- "traefik.http.routers.hospitality-dev-api.tls=true" - "traefik.http.routers.hospitality-dev-api.tls=true"
- "traefik.http.services.hospitality-dev-api.loadbalancer.server.port=8080"
web: web:
image: gitea.theriise.net/steinhelge/hospitality-frontend:dev image: gitea.theriise.net/steinhelge/hospitality-frontend:dev
@@ -21,25 +21,26 @@ services:
networks: networks:
- hospitality-net - hospitality-net
api: api:
image: gitea.theriise.net/steinhelge/hospitality-api:latest image: gitea.theriise.net/steinhelge/hospitality-api:latest
container_name: hospitality-api container_name: hospitality-api
restart: unless-stopped restart: unless-stopped
environment: environment:
ASPNETCORE_URLS: http://0.0.0.0:8080 ASPNETCORE_URLS: http://0.0.0.0:8080
# ASP.NET Core-style connection string via env: ConnectionStrings__DefaultConnection: "Host=db;Port=5432;Database=hospitality;Username=hospitality;Password=superhemmelig"
ConnectionStrings__Default: "Host=db;Port=5432;Database=hospitality;Username=hospitality;Password=supersecretpassword"
depends_on: depends_on:
- db - db
networks: networks:
- hospitality-net - hospitality-net
- edge - edge # eller hva prod-nettverket ditt heter
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.docker.network=edge" - "traefik.docker.network=edge"
- "traefik.http.routers.hospitality-api.rule=Host(`hospitality-api.theriise.net`)" - "traefik.http.routers.hospitality-api.rule=Host(`hospitality-api.theriise.net`)" # prod-domene
- "traefik.http.routers.hospitality-api.entrypoints=websecure" - "traefik.http.routers.hospitality-api.entrypoints=websecure"
- "traefik.http.routers.hospitality-api.tls=true" - "traefik.http.routers.hospitality-api.tls=true"
- "traefik.http.services.hospitality-api.loadbalancer.server.port=8080"
web: web:
image: gitea.theriise.net/steinhelge/hospitality-frontend:latest image: gitea.theriise.net/steinhelge/hospitality-frontend:latest