H
H
Horus1232021-01-15 14:16:33
Express.js
Horus123, 2021-01-15 14:16:33

How to distribute express + vue statics?

Good afternoon.
You need to save images to the project folder, and then display them in the project.
I'm trying to access the file both on the local server and on the domain, it doesn't work. What am I doing wrong?
localhost:8080/files/1.jpg
domain.ru/files/1.jpg

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

app.use('/', express.static(path.join(__dirname, 'client', 'dist')))

    app.get('*', (req, res) => {
        res.sendFile(path.resolve(__dirname, 'client', 'dist', 'index.html'))
    })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-01-15
@Horus123

Maybe so?

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question