DEV Community

Discussion on: How to deploy a Node/Express App to Vercel

Collapse
 
andrewbaisden profile image
Andrew Baisden • Edited

Do the following to get images working.

1 - Create a folder called public and put it in the root directory

2 - Add these lines to your index.js file

const path = require('path');

app.use('/static', express.static(path.join(__dirname + '/public')));
Enter fullscreen mode Exit fullscreen mode

3 - Put some images in the public folder I will use cyberpunk.png as an example

4 - See localhost and Vercel link examples below. Change the port, username and images to suit your needs.

localhost:3000/static/cyberpunk.png

vercel-node-app.yourusername.verce...