Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda