2021-03-16 14:25:15 +01:00
|
|
|
package eu.openaire.urls_controller;
|
|
|
|
|
|
|
|
import eu.openaire.urls_controller.util.UriBuilder;
|
|
|
|
import org.springframework.boot.CommandLineRunner;
|
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.core.env.Environment;
|
2021-12-21 14:55:27 +01:00
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
2021-03-16 14:25:15 +01:00
|
|
|
import org.springframework.web.cors.CorsConfiguration;
|
|
|
|
import org.springframework.web.cors.CorsConfigurationSource;
|
|
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
@SpringBootApplication
|
|
|
|
@EnableScheduling
|
|
|
|
public class Application {
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
SpringApplication.run(Application.class, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
public CorsConfigurationSource corsConfigurationSource() {
|
|
|
|
CorsConfiguration configuration = new CorsConfiguration();
|
|
|
|
configuration.setAllowedOrigins(Collections.singletonList("*"));
|
|
|
|
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
|
|
|
|
configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token"));
|
|
|
|
configuration.setExposedHeaders(Collections.singletonList("x-auth-token"));
|
|
|
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
|
|
source.registerCorsConfiguration("/**", configuration);
|
|
|
|
return source;
|
|
|
|
}
|
2022-01-30 21:14:52 +01:00
|
|
|
//
|
|
|
|
// @Bean
|
|
|
|
// public CommandLineRunner setServerBaseUrl(Environment environment) {
|
|
|
|
// return args -> new UriBuilder(environment);
|
|
|
|
// }
|
2021-03-16 14:25:15 +01:00
|
|
|
|
|
|
|
}
|