小编a4f*_*7lu的帖子

Springboot 和 Angular Websocket 的 CORS 问题

我有两个服务来构建 Spring Boot 应用程序

但我总是遇到这样的 CORS 问题

Access to XMLHttpRequest at '.../websocket-cr/info?t=1581585481804' from origin'http://localhost:8080' 
has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin'
header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. 
The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials.

Run Code Online (Sandbox Code Playgroud)

8082上的Springboot服务

    public void registerStompEndpoints(StompEndpointRegistry registry) {
       registry.addEndpoint("/websocketcr").
       setAllowedOrigins("http://localhost:8080").withSockJS();
    }
Run Code Online (Sandbox Code Playgroud)

8080 上的 Angular 服务

    var socket = new SockJS('http://localhost:8080/websocket-cr');
    //socket.withCredentials = true ;
    stompClient = …
Run Code Online (Sandbox Code Playgroud)

spring websocket sockjs

5
推荐指数
1
解决办法
8221
查看次数

如何在Vim中使用正则表达式替换为递增的数字变量

我有一个内容如下的文件:

id      phone   name
x'1234' 12345   jack
x'4567' 45678   Jojo
x'7890'  89456  Dio
x'4591'  34872  joseph
Run Code Online (Sandbox Code Playgroud)

我想把它解析成这样:

id  phone   name
1   12345   jack
2   45678   Jojo
3    89456  Dio
4    34872  joseph
Run Code Online (Sandbox Code Playgroud)

我知道基本的正则表达式可以将所有id替换为这样的任何字符串:

:%s/x'\(\w\+\)'/1/g
Run Code Online (Sandbox Code Playgroud)

它将变成:

id  phone   name
1   12345   jack
1   45678   Jojo
1    89456  Dio
1    34872  joseph
Run Code Online (Sandbox Code Playgroud)

如何将id替换为增量变量?

regex vi vim

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

标签 统计

regex ×1

sockjs ×1

spring ×1

vi ×1

vim ×1

websocket ×1