I have a React application which is running locally and Spring Cloud Gateway as BE running on a remote VPS. I get this error:
Access to XMLHttpRequest at 'http://11.1.1.5:8080/api/business_structure' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I tried to configure CORS in Spring Cloud Gateway:
application.yml
spring:
application:
name: service
cloud:
gateway:
globalcors:
cors-configurations:
'[/*]':
allowedOrigins:
- "*"
- "http://localhost:3000"
allowedMethods:
- GET
- POST
But it's not working. I'm interested why I get this error in my case? FE and BE are running on different hosts.
How I can fix this issue?