R
R
rusrich2021-02-10 20:22:50
Node.js
rusrich, 2021-02-10 20:22:50

How to use an image in react/nextjs obtained from expressJS statics?

Good evening.
There was a problem and misunderstanding. Maybe someone will tell.
In ExpressJS, I serve static files with

app.use("/static", express.static(__dirname + '/public'));

On a server on the same domain, I have two sockets with localhost:8000 - node, localhost:3000 - front on nextjs
On localhost, the image at localhost:8000/static/images/example.jpg opens. Domain.ru/static/images/example.jpg does not open on the
server . I get 404 from nextjs. Can you tell me how can I embed static images from the backend in react/nextjs?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question