Added Cors setup documentation
resolves
@@ -353,19 +353,37 @@ Thanks to https://github.com/Pyohwan[@Pyohwan]'s suggestion
So shouldn't attach @Configration. So if you have a configuration class that pulls in the springfox configuration
using the `@EnableSwagger2` like below, try removing the `@Configuration` on this class as shown below.
-```java
+[source,java]
+----
@EnableSwagger2
public class SwaggerConfig {
...
-```
+----
and use `@Import` annotation on `WebMvcConfigurerAdapter` or similar configuration class.
-```java
+[source,java]
+----
@Configuration
@EnableWebMvc
@ComponentScan(...)
@Import(SwaggerConfig.class)
public class MvcConfig extends WebMvcConfigurerAdapter {
...
-```
+----
+
+[[q21]]*21. How to add CORS support? (thanks https://github.com/gangakrishh[gangakrishh])
+Based on the https://spring.io/guides/gs/rest-service-cors/[spring guide], Creating a `WebMvcConfigurer` we can
+configure a request mapping to allow specific origins.
+
+[source,java]
+----
+ @Bean
+ public WebMvcConfigurer corsConfigurer() {
+ return new WebMvcConfigurerAdapter() {
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry.addMapping("/some-request-mapping").allowedOrigins("http://localhost:9000");
+ }
+ };
+----
