405 Method Not Allowed on POST with netlify dev --live

Hi, I’m getting 405 Method Not Allowed status on POST requests when I run netlify dev --live. This is not an issue if I’m not live. Are POST calls supposed to be supported over the live tunnel? Any idea why this may happen?

EDIT: This was happening to me on cli version 2.11.23, I’ve tried updating and am now on latest (2.32.0). Now I get another situation where my redirect doesn’t seem to apply. My SPA does not redirect /* to /index.html despite the rule being set in netlify.toml. This is also only happening on live host, not on local host.

can you tell us the name of your live site, please?

Hi @perry, wouldn’t I need to keep the live site running from my computer for you to test it? That might be hard to do, except if we agreed on a time to do it. Let me know what you suggest. And thanks for the help.

Just thought, maybe you guys have logs that you could look into (?), if that’s the case, here are some examples (retrieved from browser history, I think these will be good but might be wrong) of URLs were:

  1. I get 405 on v2.11.23: https://smplrspace-dev-028571.netlify.live/space/28b94308-13ac-4b59-83d7-fa0ceb45436d
  2. I get redirect issues on v2.32.0: https://smplrspace-dev-1f8b1b.netlify.live/space/28b94308-13ac-4b59-83d7-fa0ceb45436d

Hope this helps and thanks again

Thanks for the urls. For the 405 issue, what is the exact url you are trying to POST to? I pretty sure only a POST to lambda function or a netlify form would work, so know the url can help. However, if a newer version fixed the 405 issue, I’ll consider that part resolved.

As far as your redirects go, do you have a public repository that exhibits the issue? Maybe you are running into this change: https://github.com/netlify/cli/pull/527, which ignores SPA redirect rules.

Hi @Dennis, thanks for the response.

So you’ve nailed it with the pull 527 ignoring SPA redirect rules. Somehow in my use-case the /* -> /index.html is necessary, so the new behaviour to ignore that rule in netlify dev breaks things. I’ve gotten around that by adding a more specific rule /space/* -> /index.html which is not ignored (see PR description). Might be worth reflecting this back in the PR (?), not sure what the best way to go about this is.

The 405 issue is not resolved actually, it’s just since the redirect didn’t work, I couldn’t even reach the execution point where my 405 request is done. Here are more details: I’m POSTing to https://smplrspace-dev-81f837.netlify.live/api/v1/graphql which is supposed to hit my dev server (create-react-app) and be proxied by it to http://local.smplrspace.com:32008/v1/graphql. I supposed the call actually reaches my dev server and then things are handled locally, maybe I’m wrong?

One more thing. I previously said things work if I’m not using --live, that’s a mistake. Things work if I use my dev server port (3000) but break if I use netlify dev port (8888), whether or not i’m adding the --live option. I’ve realised this when reading the 527 PR description.

EDIT: Now I know this is framework specific, but just in case it’s helpful the proxy code:

const proxy = require('http-proxy-middleware')

module.exports = function (app) {
    proxy('/api', {
      target: 'http://local.smplrspace.com:32008',
      pathRewrite: {
        '^/\\api': ''

You cannot proxy to specific ports (e.g. :32008) right now using our proxying feature. Perhaps this is the problem?

Thanks @fool.

So how does this work actually? Would the proxying set by the react dev server happen from the browser, or does the dev server make the call to the local port and then respond without the browser having knowledge that the proxying happened? I’m thinking in the first case you might be right (and even proxying to localhost would not work), while in the second case it should not impact netlify dev (?). I understand this might be getting on the side on my specific stack and you guys might not be able to provide much more help.

Not sure we’re gonna solve this here but thanks for the support. Appreciate the clarifications received :).

Depends - if you use our proxying feature (https://docs.netlify.com/routing/redirects/rewrites-proxies/) then I guess the proxy won’t happen.

If you use some other service, I guess it will behave however that other service behaves? I don’t really know in depth how netlify dev works but I can get a developer to give us some advice if you’d like more details.

Thanks again for the feedback.

In this case it’s not using netlify proxy but my dev server’s. If you think this clarification by a dev can be useful for the community, or if there might be a wrong behavior that’s worth finding, then I’d be happy to know more as well. After that it’s not like this affects production for me so dedicate time as you see fit. :v: