0

I'm trying to feed the index.html file from my frontend build folder and I get a strange error: send deprecated hidden: use dotfiles: 'allow' instead

Here is the code I'm running:

    if (process.env.NODE_ENV === 'production') {
  app.use(
    express.static(path.join(__dirname, '../frontend/build'), {
      dotfiles: 'allow',
    })
  )

  app.get('*', (req, res) => {
    res.sendFile(__dirname, '../', 'frontend', 'build', 'index.html')
  })
} else {
  app.get('/', (req, res) => {
    res.status(200).json({ message: 'Welcome to the API' })
  })
}

Although I have set dotfiles: 'allow' , the error doesn't go away. The error appears when I acces the frontend app's main page in the browser. The main page opens, but the server crashes after that.

1 Answer 1

1

sendFile doesn't allow so many arguments

You wanted to use path.join

res.sendFile(path.join(__dirname, '../', 'frontend', 'build', 'index.html'))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.