diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/Ols4Backend.java b/backend/src/main/java/uk/ac/ebi/spot/ols/Ols4Backend.java index 849bdcd0f..76608a943 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/Ols4Backend.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/Ols4Backend.java @@ -3,6 +3,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @SpringBootApplication public class Ols4Backend { @@ -11,4 +14,14 @@ public static void main(String[] args) { SpringApplication.run(Ols4Backend.class, args); } + @Bean + public WebMvcConfigurer corsConfigurer() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/api/**").allowedOrigins("*").allowedHeaders("*").allowedMethods("GET"); + } + }; + } + } diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java b/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java index ca6d2fdaa..a1f4ac641 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java @@ -108,7 +108,7 @@ public void search( } } - if (fieldList.contains("score")) + if (fieldList != null && fieldList.contains("score")) solrQuery.setFields("_json","score"); else solrQuery.setFields("_json");