小编Kyl*_*aay的帖子

被 CORS 阻止的 Spring Gateway 请求(无 Acces0C​​ontrol-Allow-Orgin 标头)

我有一个Angular 前端spring cloud gatewayspring web service。当我尝试通过网关将 GET/POST 数据发送到 Spring Web 服务时,我收到以下错误:CORS error。当将数据直接发送到 Web 服务时,它工作正常,所以我认为问题出在网关上。

在网关中,我必须以下文件:

@Configuration
@CrossOrigin(origins = "*")
public class SpringCloudConfig {

    @Bean
    public RouteLocator gatewayRoutes(RouteLocatorBuilder builder){
        return builder.routes()
                .route(r -> r.path("/users/**")
                .uri("http://localhost:8081/")
                .id("userService"))

                .route(r -> r.path("/posts/**")
                        .uri("http://localhost:8082/")
                        .id("postService"))

                .route(r -> r.path("/auth/**")
                        .uri("http://localhost:8083/")
                        .id("securityService"))
                .build();
    }

}
Run Code Online (Sandbox Code Playgroud)

application.properties:我认为服务器:云:等等等。会做的伎俩,但没有

server.port=8080

spring:
cloud:
gateway:
globalcors:
corsConfigurations:
'[/**]':
allowedOrigins: "*"
allowedMethods:
- GET
- POST
Run Code Online (Sandbox Code Playgroud)

xml文件

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 …
Run Code Online (Sandbox Code Playgroud)

java spring gateway cors spring-cloud

4
推荐指数
2
解决办法
6466
查看次数

尝试在样式中插入打字稿元素时出现术语预期错误

在我的 ts 文件中,我有在 html 文件中使用的元素。在此示例中,我使用 element.color (值 = #3b5998)和 element.name (值 = Facebook)。当将像下面这样的值放在图标下面时,一个可以工作,但颜色不行。代码如下所示:

<fa style="color: {{element.color}};" name="{{element.icon}} fa-3x"></fa>

颜色后面:有一条红线,上面写着“预期的术语”。但我不知道该改变什么。我知道这是一个转储错误,但我被困住了。

图像

html css styling typescript angular

3
推荐指数
1
解决办法
1165
查看次数

标签 统计

angular ×1

cors ×1

css ×1

gateway ×1

html ×1

java ×1

spring ×1

spring-cloud ×1

styling ×1

typescript ×1