>PROBLEM
Attempt to access the server returns:
Refused to apply style from 'http://localhost:80/api/index' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
>SOLUTION
This kind of issue usually happens because it was not possible to reference the sources.
In this examples, the code was developed using "/" as root URL by the respective spring annotation:
@RequestMapping("/")
In this specific case this annotation may be omitted, because the framework assumes it as default, but shown here to clarify.
And the access was:
http://localhost:8047/
After, the root URL was mapped to "/sg5", using:
@RequestMapping("/sg5")
And the access was switched:
http://localhost:8047/sg5
Considering the changes also made in the security layer (in this case the spring security class), it is also required to refactor the static references adding "../" before them.
NOTES:
1. JavaScript scripts generates CORS messages instead of MIME message.
To solve, check the example below:
- BEFORE:
<script src="bootstrap/js/bootstrap.min.js"></script>
- SOLUTION: relative path was fixed:
<script src="../bootstrap/js/bootstrap.min.js"></script>
2. Possibly, It may be necessary to update the application's CORS configuration depending of its architecture.
>ENV
springboot
java17
[MYREF]:
y;faq-Refused to apply style from 'http://localhost:8047/sg5/index' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.<memo<springboot;.