0

How to serve static files with core Nodejs(not using any framework). Also, Indicate a public folder as static folder like express middleware.

   express.static(root, [options])

In my code, static files are working/serving with local development, but not working/serving some static files like .css/fonts over the https on deployment.

ndm
  • 23
  • 4
  • Idk what you mean by "core nodejs" but to serve static files in expressjs you need to use this code `app.use(express.static('./public/'))` – bogdanoff Nov 25 '22 at 04:18
  • I meant, not using any framework. (Updated the question) – ndm Nov 25 '22 at 04:19
  • This can absolutely be done, see [this question](https://stackoverflow.com/questions/16333790/node-js-quick-file-server-static-files-over-http) and [this one](https://stackoverflow.com/questions/6084360/using-node-js-as-a-simple-web-server/23122981#23122981). But a framework like Express or Koa will save you a lot of headaches. – Zac Anger Nov 25 '22 at 04:23

0 Answers0