Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #5441
Closed
Open
Issue created Oct 15, 2018 by Administrator@rootContributor

Custom proxy in CRA v2 returns 403 on POST

Created by: ghengeveld

Is this a bug report?

Yes.

Environment

Environment: OS: macOS 10.14 Node: 8.9.0 Yarn: Not Found npm: 6.4.1 Watchman: Not Found Xcode: Not Found Android Studio: 2.2 AI-145.3537739

Packages: (wanted => installed) react: 16.5.1 => 16.5.1 react-dom: 16.5.1 => 16.5.1 react-scripts: 2.0.5 => 2.0.5

[project root]
└─┬ http-proxy-middleware@0.19.0
  └── http-proxy@1.17.0

Steps to Reproduce

Previously, using react-scripts@1.1.5, I was using:

  "proxy": {
    "/checkout": {
      "target": "https://subdomain.example.org",
      "changeOrigin": true,
      "pathRewrite": {
        "^/checkout": ""
      }
    },

  }

After upgrading I followed the upgrade guide and created this src/setupProxy.js:

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

module.exports = app => {
  app.use(
    proxy("/checkout", {
      target: "https://subdomain.example.org",
      changeOrigin: true,
      pathRewrite: {
        "^/checkout": "",
      },
    })
  )
}

Expected Behavior

All requests from localhost:3000/checkout should be properly proxied to https://subdomain.example.org

Actual Behavior

All GET requests work as intended. However, a POST request returns immediately with a 403 Forbidden. Before upgrading to CRA v2 this worked fine.

Reproducible Demo

I would love to provide one, but would take considerable effort to realise. This issue has already cost me my entire working day. I have already attempted to downgrade both http-proxy-middleware and the underlying http-proxy to the versions used in CRA v1.1.5, to no avail. I've also extensively reviewed the relevant source code of react-scripts, react-dev-utils and http-proxy-middleware, but was unable to identify any change that can explain this behavior.

schermafbeelding 2018-10-15 om 16 34 00

Assignee
Assign to
Time tracking