springboot-nginx-isSameOrigin-error

codecraft

报错

java.lang.NullPointerException  
        at org.springframework.web.util.WebUtils.isSameOrigin(WebUtils.java:816)  
        at org.springframework.web.cors.DefaultCorsProcessor.processRequest(DefaultCorsProcessor.java:76)  
        at org.springframework.web.servlet.handler.AbstractHandlerMapping$CorsInterceptor.preHandle(AbstractHandlerMapping.java:503)  
        at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134)  
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:956)  
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)  
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)  
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)  
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) 

解决

nginx配置转发增加请求头

proxy_set_header        X-Real-IP       $remote_addr;  
        proxy_set_header        Host            $host;  
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;  
        proxy_pass_request_headers              on;  

参考

阅读 3.6k

code-craft
spring boot , docker and so on 欢迎关注微信公众号: geek_luandun

当一个代码的工匠回首往事时,不因虚度年华而悔恨,也不因碌碌无为而羞愧,这样,当他老的时候,可以很...

11.6k 声望
1.9k 粉丝
0 条评论
你知道吗?

当一个代码的工匠回首往事时,不因虚度年华而悔恨,也不因碌碌无为而羞愧,这样,当他老的时候,可以很...

11.6k 声望
1.9k 粉丝
文章目录
宣传栏