47 lines
1.8 KiB
Java
47 lines
1.8 KiB
Java
package eu.openaire.pdf_aggregation_statistics;
|
|
|
|
import eu.openaire.pdf_aggregation_statistics.util.UriBuilder;
|
|
import org.springframework.boot.CommandLineRunner;
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.core.env.Environment;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
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 PdfAggregationStatisticsApplication {
|
|
|
|
public static void main(String[] args) {
|
|
SpringApplication.run(PdfAggregationStatisticsApplication.class, args);
|
|
}
|
|
|
|
|
|
@Bean
|
|
public CorsConfigurationSource corsConfigurationSource() {
|
|
CorsConfiguration configuration = new CorsConfiguration();
|
|
configuration.setAllowedOrigins(Collections.singletonList("*"));
|
|
configuration.setAllowedMethods(Collections.singletonList("GET"));
|
|
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;
|
|
}
|
|
|
|
|
|
@Bean
|
|
public CommandLineRunner setServerBaseUrl(Environment environment, ServletWebServerApplicationContext webServerAppCtxt)
|
|
{
|
|
return args -> new UriBuilder(environment, webServerAppCtxt);
|
|
}
|
|
|
|
}
|