Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST requests with payload are not send to endpoint #13

Closed
zajca opened this issue Nov 2, 2018 · 5 comments
Closed

POST requests with payload are not send to endpoint #13

zajca opened this issue Nov 2, 2018 · 5 comments

Comments

@zajca
Copy link

zajca commented Nov 2, 2018

I run into this problem.

When I have proxy set like this:

  proxy: {
    '/api/':{ target: process.env.API_URL, pathRewrite: {'^/api/': ''}, logLevel: 'debug' }
  },
  axios: {
    proxy: true
  },

when I send post to url is processed by backed just fine
this.$axios.$post('/api/non-existing-url') -> 404

But when i set payload like this:

      this.$axios.$post('/jh-api/non-existing-url', {
        form': {}
      })
->
Request failed with status code 504
✖ error nuxt › proxy › [HPM] Error occurred while trying to proxy request non-existing-url from localhost:3000 to http://127.0.0.1:8082 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)

proxy-module: 1.3.1
nuxtjs/axios: 5.3.4
nuxt: 2.2.0

This question is available on Nuxt community (#c11)
@ghost ghost closed this as completed Nov 2, 2018
@ghost ghost added the cmty:question label Nov 2, 2018
@ghost
Copy link

ghost commented Nov 2, 2018

This issue as been imported as question since it does not respect proxy-module issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/proxy-module/issues/c11.

@alexanderniebuhr
Copy link

I fixed, with workaround of official github

chimurai/http-proxy-middleware#320

@Venikeee1
Copy link

Venikeee1 commented Jul 7, 2020

I fixed this issue by 'coexist-parser-proxy'. You should put it above bodyParser in nuxt.config.js

const bodyParser  = require('body-parser');

module.exports = {
  serverMiddleware: [
    'coexist-parser-proxy', // Needs to be before bodyParser
    bodyParser.json()
  ],
  proxy: {
    '/api': 'some url',
  }
}

@kalnode
Copy link

kalnode commented Sep 7, 2021

This works for me, thx.

For future: is there a pathway to not have this workaround dependency?

@root5427
Copy link

const bodyParser = require('body-parser');

module.exports = {
serverMiddleware: [
'coexist-parser-proxy', // Needs to be before bodyParser
bodyParser.json()
],
proxy: {
'/api': 'some url',
}
}

Any updates on this? Are you guys still using this workaround?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants