Skip to content

Commit

Permalink
fix: swagger server url 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
twoosky committed Aug 5, 2023
1 parent 34e5499 commit 3c68a95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
23 changes: 17 additions & 6 deletions src/main/java/com/gloddy/server/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -14,11 +15,21 @@ public class SwaggerConfig {
public OpenAPI gloddyOpenAPI() {
return new OpenAPI()
.components(new Components()
.addSecuritySchemes("JWT",
new SecurityScheme()
.type(SecurityScheme.Type.APIKEY)
.in(SecurityScheme.In.HEADER)
.name("X-AUTH-TOKEN")))
.addSecurityItem(new SecurityRequirement().addList("JWT"));
.addSecuritySchemes("JWT", securityScheme()))
.addSecurityItem(new SecurityRequirement().addList("JWT"))
.addServersItem(serversItem());
}

@Bean
public SecurityScheme securityScheme() {
return new SecurityScheme()
.type(SecurityScheme.Type.APIKEY)
.in(SecurityScheme.In.HEADER)
.name("X-AUTH-TOKEN");
}

@Bean
public Server serversItem() {
return new Server().url("/");
}
}
3 changes: 1 addition & 2 deletions src/main/java/com/gloddy/server/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public void addCorsMappings(CorsRegistry registry) {
.allowCredentials(true)
.allowedOrigins(
"http://localhost:3000",
"https://gloddy.vercel.app",
"https://api.gloddy.shop"
"https://gloddy.vercel.app"
)
.allowedMethods("*")
.allowedHeaders("*");
Expand Down

0 comments on commit 3c68a95

Please sign in to comment.