I'm using Thymeleaf with Spring Boot. When loading a page of the project site, it says that my script is being blocked because it is being returned as json instead of text/javascript.
I've included the script in the html using standard Thymeleaf templating like this:
<script type="text/javascript" th:src="@{/js/admin-register-users.js}" defer></script>
I've set up resource handling in the following way:
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/img/");
registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/");
registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
WebMvcConfigurer.super.addResourceHandlers(registry);
}
}
For some reason in the browser I get the error:
The resource from “https://localhost:8090/js/admin-register-users.js” was blocked due to MIME type (“application/json”) mismatch (X-Content-Type-Options: nosniff).