Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
Spring Boot returns js files as MIME 'application/json' instead of 'text/javascript'

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).
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Turned out to be that the file was not being found, and so a json response was returned from the server, but that response was being blocked and could not be read.

Long story short, was nothing to do with resource configuration. File was not being generated from TypeScript. So the server only found an empty js folder.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda