Added deployment modes
- CORS only apply in dev mode
This commit is contained in:
parent
a864d81bef
commit
b52128c35c
22
src/main/java/de/w665/sharepulse/config/CorsConfig.java
Normal file
22
src/main/java/de/w665/sharepulse/config/CorsConfig.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package de.w665.sharepulse.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Profile("development")
|
||||||
|
public class CorsConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
// NEVER LEAVE THIS CONFIGURATION IN PRODUCTION
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
System.out.println("CORS CONFIGURATION ENABLED | DEVELOPMENT PROFILE");
|
||||||
|
System.out.println("IF YOU SEE THIS MESSAGE IN PRODUCTION, PLEASE DISABLE DEVELOPEMENT MODE IN APPLICATION.PROPERTIES");
|
||||||
|
registry.addMapping("/api/v1/speed-test")
|
||||||
|
.allowedOrigins("*")
|
||||||
|
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||||
|
.allowedHeaders("*");
|
||||||
|
}
|
||||||
|
}
|
@ -22,3 +22,6 @@ rethinkdb.database=sharepulse
|
|||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
server.port=80
|
server.port=80
|
||||||
spring.application.name=sharepulse
|
spring.application.name=sharepulse
|
||||||
|
|
||||||
|
# Spring profiles (Options: development, production) (Controls cors)
|
||||||
|
spring.profiles.active=development
|
Loading…
x
Reference in New Issue
Block a user