From ad84ebc85178556d1ee1ee837b5cbf2bfbf7b18b Mon Sep 17 00:00:00 2001 From: Dario Ghunney Ware Date: Wed, 10 Dec 2025 10:18:14 +0000 Subject: [PATCH] set Swagger server to relative path --- .../java/stirling/software/SPDF/config/OpenApiConfig.java | 8 ++++++-- frontend/src/core/constants/links.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/core/src/main/java/stirling/software/SPDF/config/OpenApiConfig.java b/app/core/src/main/java/stirling/software/SPDF/config/OpenApiConfig.java index a25287c4d6..514b9231c6 100644 --- a/app/core/src/main/java/stirling/software/SPDF/config/OpenApiConfig.java +++ b/app/core/src/main/java/stirling/software/SPDF/config/OpenApiConfig.java @@ -62,10 +62,14 @@ public class OpenApiConfig { // Add server configuration from environment variable String swaggerServerUrl = System.getenv("SWAGGER_SERVER_URL"); + Server server; if (swaggerServerUrl != null && !swaggerServerUrl.trim().isEmpty()) { - Server server = new Server().url(swaggerServerUrl).description("API Server"); - openAPI.addServersItem(server); + server = new Server().url(swaggerServerUrl).description("API Server"); + } else { + // Use relative path so Swagger uses the current browser origin to avoid CORS issues when accessing via different ports + server = new Server().url("/").description("Current Server"); } + openAPI.addServersItem(server); // Add ErrorResponse schema to components Schema errorResponseSchema = diff --git a/frontend/src/core/constants/links.ts b/frontend/src/core/constants/links.ts index 294e993633..c48ea04ab3 100644 --- a/frontend/src/core/constants/links.ts +++ b/frontend/src/core/constants/links.ts @@ -1 +1 @@ -export const devApiLink = "/swagger-ui/index.html"; +export const devApiLink = "https://registry.scalar.com/@stirlingpdf/apis/stirling-pdf-processing-api/";