Fix Swagger UI CORS: add /api/v1 server URL to OpenAPI spec
The empty servers list caused Swagger UI to construct request URLs without the /api/v1 prefix, resulting in CORS/fetch failures. Adding a relative server entry makes paths resolve correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.springdoc.core.customizers.OpenApiCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -38,7 +39,7 @@ public class OpenApiConfig {
|
||||
return new OpenAPI()
|
||||
.info(new Info().title("Cameleer3 Server API").version("1.0"))
|
||||
.addSecurityItem(new SecurityRequirement().addList("bearer"))
|
||||
.servers(List.of());
|
||||
.servers(List.of(new Server().url("/api/v1").description("Relative")));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
Reference in New Issue
Block a user