Stylesheet not loaded because of MIME-type

前端 未结 30 2513
猫巷女王i
猫巷女王i 2020-11-22 07:29

I\'m working on a website that uses gulp to compile and browser sync to keep the browser synchronised with my changes.

The gulp task compiles everything

30条回答
  •  心在旅途
    2020-11-22 07:54

    by going into my browsers console > network > style.css ...clicked on it and it showed "cannot get /path/to/my/CSS", this told me my link was wrong. i changed that to the path of my CSS file.

    Original path before change was localhost:3000/Example/public/style.css changing it to localhost:3000/style.css solved it.

    if you are serving the file from app.use(express.static(path.join(__dirname, "public"))); or app.use(express.static("public")); your server would pass "that folder" to the browser so adding a "/yourCssName.css" link in your browser solves it

    By adding other routes in your browser CSS link, you'd be telling the browser to search for the css in route specified.

    in summary... check where your browser CSS link points to.

提交回复
热议问题