M
M
MOV_UA2020-12-01 19:39:05
Node.js
MOV_UA, 2020-12-01 19:39:05

Why does NODE give the client a picture from a static folder with Content-Type: text/html; charset=UTF-8?

const express = require('express')
const fileUpload = require('express-fileupload')
const userRouter = require('./routes/user.routes')
const dataRouter = require('./routes/data.routes')
const config = require('config')
const mongoose = require('mongoose')
const passport = require('passport')
const path = require('path')
const corsMiddleware = require('./middleware/cors')

const PORT = config.get('Server.port') || 5000

const app = express()
const pathDir = path.join(__dirname, "/uploads")
app.use(corsMiddleware)
app.use(express.static(pathDir))
app.use(passport.initialize())
require('./config/pasport')(passport)
app.use(fileUpload())

app.use(express.json())

app.use('/api/user', userRouter)
app.use('/api/data', dataRouter)

async function start() {
  try {
    await mongoose.connect(config.get('User.dbConfig.mongoUri'), {
      useNewUrlParser: true,
      useUnifiedTopology: true,
      useCreateIndex: true
    })
    app.listen(PORT, () => console.log(`Aplication has been started on port ${PORT}...`))
  } catch (error) {
    console.log(`Server error ${error.message}`)
    process.exit(1)
  }
}

start()

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