user5672375
user5672375

Reputation:

Serve Static HTML files using different route in webpack

I am using webpack to serve my files. I want to get following file.

localhost:5000/callback.html

when I give url. like

localhost:5000/logincallback

How to do that.

Upvotes: 0

Views: 998

Answers (1)

Peter
Peter

Reputation: 12711

In your webpack devServer config, you can get access to the Express app object and configure a handler for the '/logincallback' route.

Here's a sample devServer section of a larger webpack config object:

  devServer: {
    historyApiFallback: true,
    noInfo: true,
    setup(app){
      app.get('/logincallback', function(req, res) {
        res.sendFile(path.join(__dirname + '/callback.html'));
      });
    }    
  },

Upvotes: 1

Related Questions