siaorg / sia-gateway

微服务路由网关(zuul-plus)
Apache License 2.0
791 stars 345 forks source link

build & start gateway project meet the cors issue #30

Open godlockin opened 5 years ago

godlockin commented 5 years ago

OS: mac majave 10.14.6 brower: chrome 76.0.3809.132 other odds and ends are the same with deploy guidance

issue produce:

  1. git clone the sia-gateway project in master branch, prepared the java, node, maven .etc and do the build & package job.

  2. start the gateway in docker

  3. visit the url http://localhost:18086 by chrome and meet the cors issue as follow Access to XMLHttpRequest at 'http://127.0.0.1:18086/vv1/getMutiGroupNames' from origin 'http://localhost:18086' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

temporary fix the issue and make the sys accessible: add the following code in sia-gateway/sia-gateway-admin: .WebMvcConfiguration.java `@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/") .allowedOrigins("*") .allowedMethods("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "TRACE"); }`