Answers for "API requests return index.html in production"

0

API requests return index.html in production

// use this after route not before route
if (process.env.NODE_ENV === 'production') {
  app.use(express.static(resolve(process.cwd(), 'client/build')))
  app.get('*', (req, res) => {
    res.sendFile(resolve(process.cwd(), 'client/build/index.html'))
  })
}
Posted by: Guest on September-15-2020

Code answers related to "API requests return index.html in production"

Code answers related to "Javascript"

Browse Popular Code Answers by Language