Skip to content

Commit 04af5a6

Browse files
Merge pull request #50 from vimal-tech-starter/feature/new-update-contact-form-cors
Entire CorsConfig.java file with this commented-out version:
2 parents d97db18 + 4b2afce commit 04af5a6

1 file changed

Lines changed: 30 additions & 22 deletions

File tree

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
package com.vimaltech.contactapi.config;
22

3-
import org.jspecify.annotations.NonNull;
4-
import org.springframework.context.annotation.Bean;
5-
import org.springframework.context.annotation.Configuration;
6-
import org.springframework.web.servlet.config.annotation.CorsRegistry;
7-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
3+
// import org.jspecify.annotations.NonNull;
4+
// import org.springframework.context.annotation.Bean;
5+
// import org.springframework.context.annotation.Configuration;
6+
// import org.springframework.web.servlet.config.annotation.CorsRegistry;
7+
// import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
88

9-
@Configuration
10-
public class CorsConfig {
9+
/*
10+
* =========================================================================
11+
* DISABLED: CORS is now handled globally at the Nginx reverse-proxy level.
12+
* =========================================================================
13+
* If we leave this enabled, Spring Boot and Nginx will BOTH inject
14+
* Access-Control-Allow-Origin headers, causing a browser security failure.
15+
*/
1116

12-
@Bean
13-
public WebMvcConfigurer corsConfigurer() {
14-
return new WebMvcConfigurer() {
15-
@Override
16-
public void addCorsMappings(@NonNull CorsRegistry registry) {
17-
registry.addMapping("/**")
18-
.allowedOrigins(
19-
"http://localhost:3000",
20-
"https://vimaltech.dev")
21-
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
22-
.allowedHeaders("*");
23-
}
24-
};
25-
}
26-
}
17+
// @Configuration
18+
// public class CorsConfig {
19+
//
20+
// @Bean
21+
// public WebMvcConfigurer corsConfigurer() {
22+
// return new WebMvcConfigurer() {
23+
// @Override
24+
// public void addCorsMappings(@NonNull CorsRegistry registry) {
25+
// registry.addMapping("/**")
26+
// .allowedOrigins(
27+
// "http://localhost:3000",
28+
// "https://vimaltech.dev")
29+
// .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
30+
// .allowedHeaders("*");
31+
// }
32+
// };
33+
// }
34+
// }

0 commit comments

Comments
 (0)