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
  • #12512
Closed
Open
Issue created Jun 10, 2022 by Administrator@rootContributor

Bug:

Created by: MikiWiX

While using proxy (for development purposes) React is adding a "Refer" HTTP header. The contents for mentioned header is by default "http://localhost:3000", which is true for local machine it is running on. But when connecting to a remote serrver with CSRF enabled, like with Laravel, that value breaks the response causing it to fail (code 419), probably because the server treats "localhost" as different reference than our local machine. I am not sure whenever it is a bug, but maybe changing the value to actual IP of local machine will fix those issues.

React version: 18.0.0

Steps To Reproduce

  1. npx create-react-app
  2. set proxy to a remote backend server with CSRF token (tested for Laravel server)
  3. try to POST/GET any data, even the first request will fail with code 419
  4. or send the same request as react does (visible through wireshark or similiar programm) using postman/curl
  5. if we remove or modify he "Refer" header, everything will work as intended. You can input ANY String, just not localhost

The current behavior

Requests fail because of CSRF key mismatch caused by reference to localhost passed to server

The expected behavior

The server will have IP passed as a refrence, so the requests won't fail (hopefully)

Assignee
Assign to
Time tracking