Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
208 views
in Technique[技术] by (71.8m points)

java - Cross Origin doesn't work, I tried it with Spring Docs

I used for Cross Origin in my Spring Boot Cloud Gateway this Example: Spring Cloud Cross Origin

My Configuration looks like this:

spring:
  application:
    name: Gateway Service
  cloud:
    gateway:
      globalcors:
        corsConfigurations:
          '[/**]':
            allowedOrigins: "*"
      routes:
        - id: UserService
          uri: URL
          predicates:
            - Path=/service/user/**
        - id: RoleService
          uri: URL
          predicates:
            - Path=/service/role/**
        - id: VerifyService
          uri: URL
          predicates:
            - Path=/service/verify
        - id: AuthService
          uri: URL
          predicates:
            - Path=/auth/**
        - id: SchoolService
          uri: URL
          predicates:
            - Path=/service/school/**
eureka:
  client:
    fetch-registry: true
    register-with-eureka: true
    service-url:
      defaultZone: URL
server:
  port: 80

Have anyone an Idea what I did false here, because I can't reach my Application over the Cross Origin in my React App.

My "Error" in the Browserconsole is this: Access to XMLHttpRequest at 'URL' from origin 'localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I used already google and found the Docs in the Top, but after I added this, it still don't work


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...