-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
ShoppingCart/Backend/src/main/java/com/yen/ShoppingCart/config/WebConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.yen.ShoppingCart.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebConfig implements WebMvcConfigurer { | ||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") | ||
.allowedOriginPatterns("*") // SpringBoot2.4.0 [allowedOriginPatterns]代替[allowedOrigins] | ||
.allowedMethods("*") | ||
.maxAge(3600) | ||
.allowCredentials(true); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
ShoppingCart/Backend/src/main/java/com/yen/ShoppingCart/config/WebMvcConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//package com.yen.ShoppingCart.config; | ||
// | ||
//import org.springframework.context.annotation.Configuration; | ||
//import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
// | ||
//@Configuration | ||
//public class WebMvcConfig implements WebMvcConfigurer { | ||
// | ||
// @Override | ||
// public void addCorsMappings(CorsRegistry registry) { | ||
// registry.addMapping("/**") | ||
// .allowedOrigins("*") | ||
// .allowCredentials(true) | ||
// .allowedHeaders("GET", "POST", "PUT", "DELETE", "OPTIONS") | ||
// .allowedHeaders("Authorization", "Cache-Control", "Content-Type") | ||
// .maxAge(3600); | ||
// } | ||
// | ||
// public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
// registry.addResourceHandler("/swagger-ui/**") | ||
// .addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/4.10.3/"); | ||
// } | ||
// | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters