FG
🔌 APIs & SDKs

CORS error No 'Access-Control-Allow-Origin' header is present on the requested resource

Freshover 9 years ago
Mar 14, 20260 views
Confidence Score75%
75%

Problem

Hello, this is my request: ` axios({ method: 'POST', url: `${SERVER_ADDRESS}/api/v1/manager/restaurant/${restaurantName}/payment-methods`, crossDomain: true, data: { payment_methods: checkedPayments }, }) .then(() => { dispatch(loadPayments(restaurantName)); }).catch((error) => { console.log(error); dispatch(paymentsError()); }); ` the server is laravel 5, it is responding with: `XMLHttpRequest cannot load http://localhost:8000/api/v1/manager/restaurant/accusamus/payment-methods. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.` Server headers are set with CORS middleware like this: return $next($request) ->header("Access-Control-Expose-Headers", "Access-Control-") ->header("Access-Control-Allow-Headers", "Access-Control-, Origin, X-Requested-With, Content-Type, Accept") ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS, HEAD') ->header('Access-Control-Allow-Origin', '') ->header('Allow', 'GET, POST, PUT, DELETE, OPTIONS, HEAD'); Theese are the response headers, which I get when I use postman: Access-Control-Allow-Headers →Access-Control-, Origin, X-Requested-With, Content-Type, Accept Access-Control-Allow-Methods →GET, POST, PUT, DELETE, OPTI

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
74% confidence92% success rate9 verificationsLast verified Mar 14, 2026

Solution: CORS error No 'Access-Control-Allow-Origin' header is present on the requested resource

Low Risk

My server added `Access-Control-Allow-Origin` header to options request. still get the error. And it's strange that axios actually received 200 & the data server returned. Don't know why I still get the error.

74

Trust Score

9 verifications

92% success
  1. 1

    My server added `Access-Control-Allow-Origin` header to options request.

    My server added `Access-Control-Allow-Origin` header to options request.

  2. 2

    And it's strange that axios actually received 200 & the data server returned. Do

    And it's strange that axios actually received 200 & the data server returned. Don't know why I still get the error.

Validation

Resolved in axios/axios GitHub issue #569. Community reactions: 120 upvotes.

Verification Summary

Worked: 9
Partial: 2
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

axioshttpapi