如何解决Angular 8应用中的“ websocket握手过程中的错误”?

时间:2019-07-20 02:00:55

标签: angular cors

我正在尝试从网络外部(从公共Internet)登录我的应用程序。 我正在使用以下登录名:

http://203.221.66.164:80/manager/dashboard

控制台出现错误:

enter image description here

这是我的cors配置:

public class CorsFilter implements Filter {

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        final HttpServletResponse response = (HttpServletResponse) res;
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE");
        response.setHeader("Access-Control-Allow-Headers", "Authorization, Content-Type");
        response.setHeader("Access-Control-Max-Age", "3600");
        if ("OPTIONS".equalsIgnoreCase(((HttpServletRequest) req).getMethod())) {
            response.setStatus(HttpServletResponse.SC_OK);
        } else {
            chain.doFilter(req, res);
        }
    }

    @Override
    public void destroy() {
    }

    @Override
    public void init(FilterConfig config) throws ServletException {
    }

}

我能够从本地环境无错误地登录。 知道我需要更改/添加什么才能从Internet登录吗?

0 个答案:

没有答案