question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

static file like .css and .js not load error 404

See original GitHub issue

express js version : “express”: “^4.18.2”,

app.use(Express.static('public'));

express folder with app.js server code same dir i have public folder.

public/

  • app.js
  • app.css

when i try to access https://mystoreapp.io/app.js https://mystoreapp.io/app.css

getting Error 404

HTTP ERROR 404 ```

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
shree-ccommented, Nov 13, 2022

Try to remove the part of code where you set the content-security-policy header, and check if it loads. I had same issues when I used helmet package running server on bare http.

0reactions
adventuretocodecommented, Nov 16, 2022

I was just checking your code, and I don’t see the public part. Seems like you don’t create / stored / pushed the code which would allow you to query the content of the public folder

at least in this file https://github.com/Shopify/shopify-app-template-node/blob/main/server/index.js

git repo that code was same for the server i added the code into my local repo.

import Express from "express";


...
used other middleware to check the correct req 
...
app.use('/public/', Express.static('public'));  

to --> 
 app.get('/public/', Express.static('public'));

Public folder create in same directory on index.js in server folder.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error 404 when loading css in static folder - Stack Overflow
I have created CSS files in a folder static and currently I'm getting this error 404 when its trying to load the page...
Read more >
Staticfiles error 404 in Django | unable to load CSS or JS
Django unable to load static files like css, javascript, images or etc. In this type of situation, Django occurs 404 error.
Read more >
Broken pages after some time (css and js error 404)
After the FVM plugin update we are getting broken pages. After some time CSS and JS files display 404 error on the first...
Read more >
Css and Js files are giving 404 error - django-handling-static ...
The static files of the admin is getting collected but the other static files like materilize.css and materlize.js is not there in the...
Read more >
CSS Styles and javascript missing from site when not logged ...
If you use your browser's web inspector, you'll find javascript and CSS files result in a 404 missing error. Safari says can't open...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found