Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!