Search code examples
vue.jshttpnginxpostwebserver

Redirect a post request to vue application using nginx


the auth workflow we currently are using sends a post request to a specified url (our vue application) after authentication is complete. Since it's a SPA it can't receive this post request and a 405 method not allowed error is shown on the browser.

I'm currently able to get around this locally by adding something like this into my vue.config.js file:

  devServer: {
    before: function(app) {
      app.post('/', function(req, res) {
        res.redirect('/');
      });
    },
  }

But how would I configure something similar using nginx once it's actually deployed on a server?


Solution

  • anyone coming to this in the future, add the following line to nginx.conf

    error_page 405 =200 $uri;