Configure CORS, ignore unkown properties of MaterialData
This commit is contained in:
@ -2,12 +2,26 @@ package com.backend.search.service.anyame_backend;
|
||||
|
||||
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 AnyameBackendApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AnyameBackendApplication.class, args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AnyameBackendApplication.class, args);
|
||||
}
|
||||
|
||||
// TODO: Research if this is good approach or not?
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedOrigins("http://localhost:3000");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.backend.search.service.anyame_backend.api.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class MaterialData {
|
||||
|
||||
public String title;
|
||||
@ -80,4 +82,4 @@ public class MaterialData {
|
||||
public List<String> designers;
|
||||
public List<String> operators;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -29,9 +29,10 @@ public class SearchController {
|
||||
@GetMapping("/search")
|
||||
public KodikResponse search(@RequestParam("title") String title) {
|
||||
try {
|
||||
Response<KodikResponse> response = kodikAPI.search(tokenProvider.getKodikToken(), title, 5, 1).execute();
|
||||
Response<KodikResponse> response = kodikAPI.search(tokenProvider.getKodikToken(), title, 100, 1).execute();
|
||||
if (!response.isSuccessful()) {
|
||||
log.info("failed search request with title {}, response code {}, message {}", title, response.code(), response.message());
|
||||
log.info("failed search request with title {}, response code {}, message {}", title, response.code(),
|
||||
response.message());
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "bad response, code: " + response.code());
|
||||
}
|
||||
return response.body();
|
||||
|
Reference in New Issue
Block a user