Issue
I get this error: Refused to execute script from 'http://localhost:53134/home.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
when I reload home page with following code(home.html):
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/">
<link rel="stylesheet" type="text/css" href="output.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body class="screen">
<div class="navBar">
<a href='/'>Home</a>
<a href='/wallet'>Wallet</a>
<a href='/login'>Login</a>
</div>
<p class="letters">Home page</p>
<script src="home.js"></script> <!-- this is a problem -->
</body>
</html>
When I use console.log('hello'); inside home.html
then that is not a problem, but when I add the code in home.js then it appears to be a problem. How to solve this?
and this script(home.js):
console.log('hello');
Solution
The problem was on a backend.. I've used app.use(express.static('public'));
which caused wrong route for js file.. It should've been <script src="js/home.js"></script>
Answered By - Ged0jzn4 Answer Checked By - Mildred Charles (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.