Express JS - Serving Static Files

preview_player
Показать описание
This tutorial explains how you can send back static files like CSS or images from your Express JS web server or API without having to create a specific route for every single file.

Рекомендации по теме
Комментарии
Автор

time and time again you come to save my life😭❤

mandlankosi
Автор

Your explanation is very clear Sir. The first time I saw a video I immediately subscribed your channel. Thank you and warm greetings from Indonesia. Jesus bless🙏🙏🙏

valentinussofa
Автор

You explain things so clearly. Thank you so much for this!

nowayfc
Автор

Much needed stuff! I love your bite-sized content :)

brandondabreo
Автор

you are soo much better than the udemy instructors out there.

sandeepmourya
Автор

Hiya Thank you so very much mate!
Btw your voice is the most reverberating voice I've heard in my whole god damn life! May God Bless You and Keep Doing the Great deeds!
Cheers Mate!:)

tanishq
Автор

how can we do this if you have frontend and backend separate and server.js is running in backend.? how can we save file in frontend public folder?

TechWrathTV
Автор

superb teaching as always. Sir Please make videos on React as well.

LunaLovelyy
Автор

How many browsers do you have?
Steve: Yes.

selimmidikoglu
Автор

Hi, I've been trying to get this working... once I set up a static dirname to my webapp folder, the routes like app.get("/"... will no longer trigger (?) I can either have the frontend displayed OR the routes triggered, but not both... Mind to help out? Thanks!

pikolino
Автор

Please explicitly ask people to like! else people would forget! but they are being helped....

Suvro
Автор

how can i show pdf file in iframe by this static method?

NiajMohammadKrishnopakkho
Автор

What if you have a usual CSR React app. But it has a large landing page and you want to reduce the initial loading time?
How would you render it(or any specific page) on build time to make it fast and crawable?

Just like putting a favicon in your public folder - and then using express.static to declare where it can be found - maybe you can do the same thing with an html file for a specific page?
But the html file needs to be generated somehow.
Preferably without some fancy framework.

jhannes
Автор

Hi, I was facing an issue

like when the endpoint is : localhost:3000/add => the static files are served
if i go : locahlost:3000/api/add => the files are not getting served


it looks for api/js/main.js like that and fails to load the css js files .

Thanks in advance

arunkutz
Автор

Do we not require "npm i mime-types" module in express to determine mime type as we did in core node OR express handle automatic?

aimanzaheb
Автор

Hi, Do we have a way to restrict files like web.config inside public folder as same as you did to dotfiles?

pawansasanka
Автор

I tried using express.static("public/css" ) but that didn't worked, how can i make it work

nizarkadri
Автор

Hey Steve,
can we make Asynchronous API calls from the files that are located in static defined folder ? if we can then what's the point of using template engines to render dynamic data?
Thanks in advance

gowthambhat
Автор

Hi Steve, favicon works, but jpeg or gif still don't load?

scoperbubba
Автор

Holy smokes what mic / recording software do you have? Also nice vid!

imdabes