Skip to content

Regression: Static JS files served as 'application/octet-stream' instead of 'application/javascript' [SPR-14368] #18940

Closed
@spring-projects-issues

Description

@spring-projects-issues

Luis Lebolo opened SPR-14368 and commented

I upgraded from Spring 4.2.6 to 4.3.0 and now I'm receiving the following error in Chrome when my web page tries to load static javascript files.

Refused to execute script from http://.../someJsFile.js because its MIME type ('application/octet-stream') is not executable, and strict MIME type checking is enabled.

I double-checked the response header (using Spring 4.3.0) and I indeed see Content-Type:application/octet-stream. However, when I drop back down to Spring 4.2.6 I see Content-Type:application/javascript.

The files are included in my page like

<!DOCTYPE html>
<html lang="en">
<!-- ... -->
<body>
  <!-- ... -->
  <!-- Adding type="text/javascript" does not help -->
  <script src="/resources/js/someJsFile.js"></script>
</body>
</html>

and my config looks like

<!-- ... -->
<context:component-scan base-package="some.package.spec" />	
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
<!-- ... -->

I tried looking at the Spring 4.3.0 release notes, but nothing immediately stood out (maybe #17493).

Any ideas what changes in 4.3.0 are affecting me? How do I tell Spring 4.3.0 to set the correct content type for static javascript files? Let me know if you need more details about configuration, etc. Unfortunately, I don't think I could package up the project - it's quite complex and lots of proprietary info.


Affects: 4.3 GA

Reference URL: http://stackoverflow.com/questions/37822460/upgraded-to-spring-4-3-0-and-static-js-files-are-now-served-as-application-octe

Issue Links:

Referenced from: commits e38623d

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions