Linking to a static file from a generated html

URLs of static files.

I am generating a html page dynamically with js and serving with http. I want to link to static css and image files that are stored in directories in my replit. How do I find the URLs of static files in my replit that can be used in my generated html.

Instructions here

https://docs.replit.com/hosting/hosting-web-pages

Don’t access the static files.

e.g. https://jalendu.marqandrew.repl.co/public/images/logo.jpg

Problem may be that my node.js replit that generates the html is private. I can’t make it public because it contains sensitive data.

Solution: Create another public replit that is a HTML, CSS, JS Replit then link to its resources. You can find the base url by going to the webview window.

What are you using for your backend?
Express? If so, you can use express.static:

app.use('/public', express.static('public'))

This serves the public folder under the /public prefix.

1 Like