Refused to apply style from 'http://localhost:3000/style.css' because its MIME type ('text/html')

C96

I have this error when I run my client server JS application

CONSOLE ERROR IN DevTools:

Refused to apply style from 'http://localhost:3000/style.css' because its MIME type 
('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

CLIENT CODE:

const postData = async ( url = '', data = {})=>{
console.log(data);
const response = await fetch(url, {
  method: 'POST', 
  credentials: 'same-origin',
  headers: {
      'Content-Type': 'application/json',
  },
 // Body data type must match "Content-Type" header        
  body: JSON.stringify(data), 
});

  try {
    const newData = await response.json();
    console.log(newData);
    return newData;
  }catch(error) {
  console.log("error", error);
  }
 }

postData('/addMovie', {answer:42});

SERVER CODE:

const express = require('express')
const bodyParser = require('body-parser');
const app = express()

app.use(bodyParser.urlencoded({extended : false}));
app.use(bodyParser.json());

const cors = require('cors');
app.use(cors());
app.use(express.static('website'))

const port = 3000
app.listen(port, getServerPortInfo)
function getServerPortInfo() {
    console.log("Server listening at port " + port)
}

const data = []
app.post('/addMovie', addMovie)

function addMovie (req, res){
    console.log(req.body)
    console.log("here")
    data.push(req.body)
    console.log(data)
    res.send(data)

 }

HTML FILE:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Weather Journal</title>
    <link href="https://fonts.googleapis.com/css?family=Oswald:400,600,700|Ranga:400,700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
</head>
<body>    
    <div>
        <button id="generate" type = "submit"> Generate </button>
    </div>
    <script src="app.js" type="text/javascript"></script>
</body>
</html>

Could you please provide some links, advice, or pointers that would help direct me towards a solution?

The strange thing is that I do not have a css file.

Please note that I have already gone through this post and it has not helped my case: The console of Chrome error : Refused to apply style because its MIME type ('text/html')

Wyck

You have specified:

<link rel="stylesheet" href="style.css">

But you do not have a style.css file. The request for http://localhost:3000/style.css has resulted in a 404 error, and your server has served up an HTML response (mimetype is text/html). The error says it all:

Refused to apply style from 'http://localhost:3000/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

To correct the problem, either link to the actual style.css with a full URL, or remove the stylesheet link entirely if no such style.css resource exists anywhere.

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Refused to execute script from '*' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled

Refused to execute script from '*.ts' because its MIME type ('video/vnd.dlna.mpeg-tts') is not executable

Error on minification in console "Refused to execute because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled"

Node/Express - Refused to apply style because its MIME type ('text/html')

Refused to apply style from... because its MIME type ('text/html') is not a supported style-sheet MIME type, and strict MIME checking is enabled

Refused to apply style from '' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

Refused to execute script from because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled

Refused to apply style because its MIME type "text/html" is not supported stylesheet MIME type, and strict MIME checking is enabled

Node refused to apply style because its MIME type ('text/html') is not a supported stylesheet MIME

Refused to execute script from 'file_name.php' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled

Refused to apply style from 'http://localhost:1234/node_modules/primeicons/primeicons.css' because its MIME type ('text/html')

Webpack "Refused to apply style from leaflet.css"

Tensorboard is showing a blank page (Refused to execute script from 'http://localhost:6006/index.js' because its MIME type)

Refused to execute script from '..../angular.min.js' because its MIME type ('application/octet_stream') is not executable, and strict MIME type check

Refused to apply style from auth/css when rendering

Chrome and Spring security: Refused to execute script from 'http://<server url>/assets/app.js' because its MIME type ('') is not executable

Rewrite requests from loopback to angular2 (Refused to execute script because its MIME type ('text/html') is not executable)

Refused to execute script from URL because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled

Refused to apply style from [Link] because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

The stylesheet style.css was not loaded because its MIME type, “text/plain”, is not “text/css”

html view can not load css style because of MIME-type error

Refused to execute script from 'url' because its MIME type ('image/jpeg') is not executable

Webpack + React.lazy + nested routing: Refused to apply style from '*/css/main.css' because its MIME type ('text/html')

Refused to apply style from 'URL' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

Refused to apply style because its MIME type ('text/html') is not a supported stylesheet MIME type

"Refused to apply style from because its MIME type "('font/woff2')" is not a supported stylesheet MIME type, and strict MIME checking is enabled"

content is not loading because its MIME type, "text/html" is not "text/css"

Refused to display style because MIME type

(Node Express)Refused to apply style because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled