Skip to content

Commit

Permalink
Merge pull request #596 from EBISPOT/#590
Browse files Browse the repository at this point in the history
#590 and CORS fix
  • Loading branch information
henrietteharmse authored Nov 27, 2023
2 parents 4ccbc98 + 82c2524 commit 280a0f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions backend/src/main/java/uk/ac/ebi/spot/ols/Ols4Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
}
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 280a0f1

Please sign in to comment.