I'm getting a forbidden OPTIONS for requests made from Chrome. Here is my application.yml:
spring:
application:
name: gateway-service
cloud:
gateway:
routes:
# =====================================
- id: options
uri: http://localhost:8080
predicates:
- Path=/event
Here is the request on Chrome: https://image.ibb.co/gA3Kk6/request.png. On the log bellow the gateway does not even tries to forward the request to the other service. It just gives Successfully completed request -> No sendHeaders() called before complete.
2017-11-15 16:50:44.031 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.http.server.HttpServer : [id: 0x1474952e, L:/0:0:0:0:0:0:0:0:8090] READ: [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862]
2017-11-15 16:50:44.031 DEBUG 8508 --- [ctor-http-nio-1] r.i.n.http.server.HttpServerOperations : New http connection, requesting read
2017-11-15 16:50:44.031 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.channel.ContextHandler : After pipeline DefaultChannelPipeline{(reactor.left.loggingHandler = io.netty.handler.logging.LoggingHandler), (ServerContextHandler#0 = reactor.ipc.netty.channel.ServerContextHandler), (reactor.left.httpDecoder = io.netty.handler.codec.http.HttpRequestDecoder), (reactor.left.httpEncoder = io.netty.handler.codec.http.HttpResponseEncoder), (reactor.left.httpServerHandler = reactor.ipc.netty.http.server.HttpServerHandler), (reactor.right.reactiveBridge = reactor.ipc.netty.channel.ChannelOperationsHandler)}
2017-11-15 16:50:44.031 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.http.server.HttpServer : [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] REGISTERED
2017-11-15 16:50:44.031 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.http.server.HttpServer : [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] ACTIVE
2017-11-15 16:50:44.031 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.http.server.HttpServer : [id: 0x1474952e, L:/0:0:0:0:0:0:0:0:8090] READ COMPLETE
2017-11-15 16:50:44.032 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.http.server.HttpServer : [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] READ: 432B
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 4f 50 54 49 4f 4e 53 20 2f 65 76 65 6e 74 20 48 |OPTIONS /event H|
|00000010| 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 6c |TTP/1.1..Host: l|
|00000020| 6f 63 61 6c 68 6f 73 74 3a 38 30 39 30 0d 0a 43 |ocalhost:8090..C|
|00000030| 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d |onnection: keep-|
|00000040| 61 6c 69 76 65 0d 0a 41 63 63 65 73 73 2d 43 6f |alive..Access-Co|
|00000050| 6e 74 72 6f 6c 2d 52 65 71 75 65 73 74 2d 4d 65 |ntrol-Request-Me|
|00000060| 74 68 6f 64 3a 20 47 45 54 0d 0a 4f 72 69 67 69 |thod: GET..Origi|
|00000070| 6e 3a 20 68 74 74 70 3a 2f 2f 6c 6f 63 61 6c 68 |n: http://localh|
|00000080| 6f 73 74 0d 0a 55 73 65 72 2d 41 67 65 6e 74 3a |ost..User-Agent:|
|00000090| 20 4d 6f 7a 69 6c 6c 61 2f 35 2e 30 20 28 57 69 | Mozilla/5.0 (Wi|
|000000a0| 6e 64 6f 77 73 20 4e 54 20 31 30 2e 30 3b 20 57 |ndows NT 10.0; W|
|000000b0| 69 6e 36 34 3b 20 78 36 34 29 20 41 70 70 6c 65 |in64; x64) Apple|
|000000c0| 57 65 62 4b 69 74 2f 35 33 37 2e 33 36 20 28 4b |WebKit/537.36 (K|
|000000d0| 48 54 4d 4c 2c 20 6c 69 6b 65 20 47 65 63 6b 6f |HTML, like Gecko|
|000000e0| 29 20 43 68 72 6f 6d 65 2f 36 32 2e 30 2e 33 32 |) Chrome/62.0.32|
|000000f0| 30 32 2e 39 34 20 53 61 66 61 72 69 2f 35 33 37 |02.94 Safari/537|
|00000100| 2e 33 36 0d 0a 41 63 63 65 73 73 2d 43 6f 6e 74 |.36..Access-Cont|
|00000110| 72 6f 6c 2d 52 65 71 75 65 73 74 2d 48 65 61 64 |rol-Request-Head|
|00000120| 65 72 73 3a 20 63 6f 6e 74 65 6e 74 2d 74 79 70 |ers: content-typ|
|00000130| 65 0d 0a 41 63 63 65 70 74 3a 20 2a 2f 2a 0d 0a |e..Accept: */*..|
|00000140| 44 4e 54 3a 20 31 0d 0a 41 63 63 65 70 74 2d 45 |DNT: 1..Accept-E|
|00000150| 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70 2c 20 64 |ncoding: gzip, d|
|00000160| 65 66 6c 61 74 65 2c 20 62 72 0d 0a 41 63 63 65 |eflate, br..Acce|
|00000170| 70 74 2d 4c 61 6e 67 75 61 67 65 3a 20 65 6e 2d |pt-Language: en-|
|00000180| 47 42 2c 65 6e 3b 71 3d 30 2e 39 2c 65 6e 2d 55 |GB,en;q=0.9,en-U|
|00000190| 53 3b 71 3d 30 2e 38 2c 70 74 2d 50 54 3b 71 3d |S;q=0.8,pt-PT;q=|
|000001a0| 30 2e 37 2c 70 74 3b 71 3d 30 2e 36 0d 0a 0d 0a |0.7,pt;q=0.6....|
+--------+-------------------------------------------------+----------------+
2017-11-15 16:50:44.032 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.http.server.HttpServer : [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] READ COMPLETE
2017-11-15 16:50:44.039 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.channel.ChannelOperations : [HttpServer] [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@5c34ce70
2017-11-15 16:50:44.039 DEBUG 8508 --- [ctor-http-nio-1] o.s.web.reactive.DispatcherHandler : Processing OPTIONS request for [http://localhost:8090/event]
2017-11-15 16:50:44.039 DEBUG 8508 --- [ctor-http-nio-1] s.w.r.r.m.a.RequestMappingHandlerMapping : Looking up handler method for path /event
2017-11-15 16:50:44.039 DEBUG 8508 --- [ctor-http-nio-1] s.w.r.r.m.a.RequestMappingHandlerMapping : Did not find handler method for [/event]
2017-11-15 16:50:44.039 TRACE 8508 --- [ctor-http-nio-1] o.s.c.g.h.p.RoutePredicateFactory : Pattern "/gateway-service/**" does not match against value "[path='/event']"
2017-11-15 16:50:44.040 TRACE 8508 --- [ctor-http-nio-1] o.s.c.g.h.p.RoutePredicateFactory : Pattern "/event" matches against value "[path='/event']"
2017-11-15 16:50:44.040 DEBUG 8508 --- [ctor-http-nio-1] o.s.c.g.h.RoutePredicateHandlerMapping : RouteDefinition matched: options
2017-11-15 16:50:44.040 DEBUG 8508 --- [ctor-http-nio-1] o.s.c.g.h.RoutePredicateHandlerMapping : Mapping [Exchange: OPTIONS http://localhost:8090/event] to Route{id='options', uri=http://localhost:8080, order=0, predicate=org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$303/1681629677@7ed2c951, gatewayFilters=[OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.RemoveNonProxyHeadersGatewayFilterFactory$$Lambda$305/561133045@20755db2, order=1}]}
2017-11-15 16:50:44.040 DEBUG 8508 --- [ctor-http-nio-1] o.s.h.s.r.ReactorHttpHandlerAdapter : Successfully completed request
2017-11-15 16:50:44.040 DEBUG 8508 --- [ctor-http-nio-1] r.i.n.http.server.HttpServerOperations : Last HTTP response frame
2017-11-15 16:50:44.040 DEBUG 8508 --- [ctor-http-nio-1] r.i.n.http.server.HttpServerOperations : No sendHeaders() called before complete, sending zero-length header
2017-11-15 16:50:44.040 DEBUG 8508 --- [ctor-http-nio-1] r.i.n.channel.ChannelOperationsHandler : [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] Writing object DefaultFullHttpResponse(decodeResult: success, version: HTTP/1.1, content: EmptyByteBufBE)
HTTP/1.1 403 Forbidden
content-length: 0
2017-11-15 16:50:44.040 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.http.server.HttpServer : [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] WRITE: 45B
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 48 54 54 50 2f 31 2e 31 20 34 30 33 20 46 6f 72 |HTTP/1.1 403 For|
|00000010| 62 69 64 64 65 6e 0d 0a 63 6f 6e 74 65 6e 74 2d |bidden..content-|
|00000020| 6c 65 6e 67 74 68 3a 20 30 0d 0a 0d 0a |length: 0.... |
+--------+-------------------------------------------------+----------------+
2017-11-15 16:50:44.040 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.http.server.HttpServer : [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] FLUSH
2017-11-15 16:50:44.041 DEBUG 8508 --- [ctor-http-nio-1] r.ipc.netty.http.server.HttpServer : [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] USER_EVENT: [Handler Terminated]
2017-11-15 16:50:44.041 DEBUG 8508 --- [ctor-http-nio-1] r.i.n.channel.ChannelOperationsHandler : [id: 0xccbab450, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57862] Disposing context reactor.ipc.netty.channel.ServerContextHandler@49fd2ef5
In the other hand a OPTION request from Postman, for the same configuration, goes without errors:
2017-11-15 16:51:49.059 DEBUG 8508 --- [ctor-http-nio-2] r.ipc.netty.http.server.HttpServer : [id: 0x21865bd0, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57850] READ: 587B
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 4f 50 54 49 4f 4e 53 20 2f 65 76 65 6e 74 20 48 |OPTIONS /event H|
|00000010| 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 6c |TTP/1.1..Host: l|
|00000020| 6f 63 61 6c 68 6f 73 74 3a 38 30 39 30 0d 0a 43 |ocalhost:8090..C|
|00000030| 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d |onnection: keep-|
|00000040| 61 6c 69 76 65 0d 0a 41 63 63 65 70 74 3a 20 61 |alive..Accept: a|
|00000050| 70 70 6c 69 63 61 74 69 6f 6e 2f 76 6e 64 2e 67 |pplication/vnd.g|
|00000060| 65 74 73 63 72 61 6d 6a 65 74 2e 61 70 69 2d 76 |et.api-v|
|00000070| 31 2b 6a 73 6f 6e 0d 0a 43 61 63 68 65 2d 43 6f |1+json..Cache-Co|
|00000080| 6e 74 72 6f 6c 3a 20 6e 6f 2d 63 61 63 68 65 0d |ntrol: no-cache.|
|00000090| 0a 4f 72 69 67 69 6e 3a 20 63 68 72 6f 6d 65 2d |.Origin: chrome-|
|000000a0| 65 78 74 65 6e 73 69 6f 6e 3a 2f 2f 66 68 62 6a |extension://fhbj|
|000000b0| 67 62 69 66 6c 69 6e 6a 62 64 67 67 65 68 63 64 |gbiflinjbdggehcd|
|000000c0| 64 63 62 6e 63 64 64 64 6f 6d 6f 70 0d 0a 55 73 |dcbncdddomop..Us|
|000000d0| 65 72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 6c 6c |er-Agent: Mozill|
|000000e0| 61 2f 35 2e 30 20 28 57 69 6e 64 6f 77 73 20 4e |a/5.0 (Windows N|
|000000f0| 54 20 31 30 2e 30 3b 20 57 69 6e 36 34 3b 20 78 |T 10.0; Win64; x|
|00000100| 36 34 29 20 41 70 70 6c 65 57 65 62 4b 69 74 2f |64) AppleWebKit/|
|00000110| 35 33 37 2e 33 36 20 28 4b 48 54 4d 4c 2c 20 6c |537.36 (KHTML, l|
|00000120| 69 6b 65 20 47 65 63 6b 6f 29 20 43 68 72 6f 6d |ike Gecko) Chrom|
|00000130| 65 2f 36 32 2e 30 2e 33 32 30 32 2e 39 34 20 53 |e/62.0.3202.94 S|
|00000140| 61 66 61 72 69 2f 35 33 37 2e 33 36 0d 0a 50 6f |afari/537.36..Po|
|00000150| 73 74 6d 61 6e 2d 54 6f 6b 65 6e 3a 20 33 39 39 |stman-Token: 399|
|00000160| 65 65 39 31 66 2d 66 62 35 65 2d 37 65 38 36 2d |ee91f-fb5e-7e86-|
|00000170| 61 33 35 33 2d 65 30 64 36 62 31 35 66 32 30 37 |a353-e0d6b15f207|
|00000180| 34 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a |4..Content-Type:|
|00000190| 20 61 70 70 6c 69 63 61 74 69 6f 6e 2f 76 6e 64 | application/vnd|
|000001a0| 2e 67 65 74 73 63 72 61 6d 6a 65 74 2e 61 70 69 |.get.api|
|000001b0| 2d 76 31 2b 6a 73 6f 6e 0d 0a 44 4e 54 3a 20 31 |-v1+json..DNT: 1|
|000001c0| 0d 0a 41 63 63 65 70 74 2d 45 6e 63 6f 64 69 6e |..Accept-Encodin|
|000001d0| 67 3a 20 67 7a 69 70 2c 20 64 65 66 6c 61 74 65 |g: gzip, deflate|
|000001e0| 2c 20 62 72 0d 0a 41 63 63 65 70 74 2d 4c 61 6e |, br..Accept-Lan|
|000001f0| 67 75 61 67 65 3a 20 65 6e 2d 47 42 2c 65 6e 3b |guage: en-GB,en;|
|00000200| 71 3d 30 2e 39 2c 65 6e 2d 55 53 3b 71 3d 30 2e |q=0.9,en-US;q=0.|
|00000210| 38 2c 70 74 2d 50 54 3b 71 3d 30 2e 37 2c 70 74 |8,pt-PT;q=0.7,pt|
|00000220| 3b 71 3d 30 2e 36 0d 0a 43 6f 6f 6b 69 65 3a 20 |;q=0.6..Cookie: |
|00000230| 69 6f 3d 6b 56 47 4f 77 67 46 5a 36 61 37 71 54 |io=kVGOwgFZ6a7qT|
|00000240| 44 37 5f 41 41 41 43 0d 0a 0d 0a |D7_AAAC.... |
+--------+-------------------------------------------------+----------------+
2017-11-15 16:51:49.060 DEBUG 8508 --- [ctor-http-nio-2] r.ipc.netty.http.server.HttpServer : [id: 0x21865bd0, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57850] READ COMPLETE
2017-11-15 16:51:49.060 DEBUG 8508 --- [ctor-http-nio-2] r.ipc.netty.channel.ChannelOperations : [HttpServer] [id: 0x21865bd0, L:/0:0:0:0:0:0:0:1:8090 - R:/0:0:0:0:0:0:0:1:57850] handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@5c34ce70
2017-11-15 16:51:49.060 DEBUG 8508 --- [ctor-http-nio-2] o.s.web.reactive.DispatcherHandler : Processing OPTIONS request for [http://localhost:8090/event]
2017-11-15 16:51:49.060 DEBUG 8508 --- [ctor-http-nio-2] s.w.r.r.m.a.RequestMappingHandlerMapping : Looking up handler method for path /event
2017-11-15 16:51:49.063 DEBUG 8508 --- [ctor-http-nio-2] s.w.r.r.m.a.RequestMappingHandlerMapping : Did not find handler method for [/event]
2017-11-15 16:51:49.063 TRACE 8508 --- [ctor-http-nio-2] o.s.c.g.h.p.RoutePredicateFactory : Pattern "/gateway-service/**" does not match against value "[path='/event']"
2017-11-15 16:51:49.063 TRACE 8508 --- [ctor-http-nio-2] o.s.c.g.h.p.RoutePredicateFactory : Pattern "/event" matches against value "[path='/event']"
2017-11-15 16:51:49.063 DEBUG 8508 --- [ctor-http-nio-2] o.s.c.g.h.RoutePredicateHandlerMapping : RouteDefinition matched: options
2017-11-15 16:51:49.063 DEBUG 8508 --- [ctor-http-nio-2] o.s.c.g.h.RoutePredicateHandlerMapping : Mapping [Exchange: OPTIONS http://localhost:8090/event] to Route{id='options', uri=http://localhost:8080, order=0, predicate=org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$303/1681629677@7ed2c951, gatewayFilters=[OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.RemoveNonProxyHeadersGatewayFilterFactory$$Lambda$305/561133045@20755db2, order=1}]}
2017-11-15 16:51:49.063 DEBUG 8508 --- [ctor-http-nio-2] o.s.c.g.handler.FilteringWebHandler : Sorted gatewayFilterFactories: [OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@1b1f5012}, order=-1}, OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.RemoveNonProxyHeadersGatewayFilterFactory$$Lambda$305/561133045@20755db2, order=1}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@7add323c}, order=10000}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@660f0c}, order=10100}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyRoutingFilter@7a0ef219}, order=2147483647}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardRoutingFilter@4a734c04}, order=2147483647}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@4760f169}, order=2147483647}]
2017-11-15 16:51:49.064 TRACE 8508 --- [ctor-http-nio-2] o.s.c.g.filter.RouteToRequestUrlFilter : RouteToRequestUrlFilter start
2017-11-15 16:51:49.064 DEBUG 8508 --- [ctor-http-nio-2] r.i.n.c.PooledClientContextHandler : Acquiring existing channel from pool: DefaultPromise@94be4f(incomplete) SimpleChannelPool{activeConnections=0}
2017-11-15 16:51:49.065 DEBUG 8508 --- [ctor-http-nio-3] r.i.n.resources.DefaultPoolResources : Created [id: 0x29960b00], now 1 active connections
2017-11-15 16:51:49.066 DEBUG 8508 --- [ctor-http-nio-3] r.ipc.netty.channel.ContextHandler : After pipeline DefaultChannelPipeline{(reactor.left.loggingHandler = io.netty.handler.logging.LoggingHandler), (SimpleChannelPool$1#0 = io.netty.channel.pool.SimpleChannelPool$1), (reactor.left.httpDecoder = io.netty.handler.codec.http.HttpResponseDecoder), (reactor.left.httpEncoder = io.netty.handler.codec.http.HttpRequestEncoder), (reactor.right.reactiveBridge = reactor.ipc.netty.channel.ChannelOperationsHandler)}
2017-11-15 16:51:49.066 DEBUG 8508 --- [ctor-http-nio-3] r.ipc.netty.http.client.HttpClient : [id: 0x29960b00] REGISTERED
2017-11-15 16:51:49.066 DEBUG 8508 --- [ctor-http-nio-3] r.ipc.netty.http.client.HttpClient : [id: 0x29960b00] CONNECT: localhost/127.0.0.1:8080
2017-11-15 16:51:49.066 DEBUG 8508 --- [ctor-http-nio-3] r.ipc.netty.http.client.HttpClient : [id: 0x29960b00, L:/127.0.0.1:57974 - R:localhost/127.0.0.1:8080] ACTIVE
2017-11-15 16:51:49.066 DEBUG 8508 --- [ctor-http-nio-3] r.i.n.c.PooledClientContextHandler : Acquired active channel: [id: 0x29960b00, L:/127.0.0.1:57974 - R:localhost/127.0.0.1:8080]
2017-11-15 16:51:49.067 DEBUG 8508 --- [ctor-http-nio-3] r.ipc.netty.channel.ChannelOperations : [HttpClient] [id: 0x29960b00, L:/127.0.0.1:57974 - R:localhost/127.0.0.1:8080] handler is being applied: HttpClientHandler{startURI=http://localhost:8080/event, method=OPTIONS, handler=org.springframework.cloud.gateway.filter.NettyRoutingFilter$$Lambda$394/1337039639@50b26528}
2017-11-15 16:51:49.067 DEBUG 8508 --- [ctor-http-nio-3] r.ipc.netty.http.client.HttpClient : [id: 0x29960b00, L:/127.0.0.1:57974 - R:localhost/127.0.0.1:8080] USER_EVENT: reactor.ipc.netty.NettyPipeline$SendOptionsChangeEvent@b356176
2017-11-15 16:51:49.067 DEBUG 8508 --- [ctor-http-nio-3] r.i.n.channel.ChannelOperationsHandler : [id: 0x29960b00, L:/127.0.0.1:57974 - R:localhost/127.0.0.1:8080] New sending options
2017-11-15 16:51:49.067 DEBUG 8508 --- [ctor-http-nio-3] r.i.n.channel.ChannelOperationsHandler : [id: 0x29960b00, L:/127.0.0.1:57974 - R:localhost/127.0.0.1:8080] Writing object DefaultFullHttpRequest(decodeResult: success, version: HTTP/1.1, content: UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf(ridx: 0, widx: 0, cap: 0))
OPTIONS /event HTTP/1.1
Accept: application/vnd.get.api-v1+json
Cache-Control: no-cache
Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Postman-Token: 399ee91f-fb5e-7e86-a353-e0d6b15f2074
Content-Type: application/vnd.get.api-v1+json
DNT: 1
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en;q=0.9,en-US;q=0.8,pt-PT;q=0.7,pt;q=0.6
Cookie: io=kVGOwgFZ6a7qTD7_AAAC
host: localhost:8080
content-length: 0
2017-11-15 16:51:49.068 DEBUG 8508 --- [ctor-http-nio-3] r.ipc.netty.http.client.HttpClient : [id: 0x29960b00, L:/127.0.0.1:57974 - R:localhost/127.0.0.1:8080] WRITE: 582B
Is there any forbidden header that I must remove first?
Thanks,
Pedro
Update:
The header causing this:
Access-Control-Request-Method: GET
Any value different than empty will cause the OPTION request to fail.
I tried to add a filter (RemoveRequestHeader) to remove this header from the request, but I think that this crashes before that.
From what I investigated, spring-cloud-gateway starts a netty httpserver and all the solutions on the internet to enable cors and/or dispatchOptionsRequest only works for Spring MVC/tomcat right?
@pedrohh so far, I don't see anything specific to the gateway, more likely the netty server support in spring-boot or spring-framework
@spencergibb do you know any way to have access to the netty server configuration? That way I could add some configuration like this.
Nope, hence my mention of the boot and framework teams.
I have found solution using web filter https://stackoverflow.com/a/47494858/3523298
@muzuro I didn't find a solution, but I will try yours thanks!
麓
UPDATE: It works, thanks @muzuro @spencergibb
Closing this due to inactivity. Please re-open if there's more to discuss.
Hi, we also met OPTIONS issue. Unfortunatelly for us allowedMethods("*") in option only for testing purpose.
The ideal solution will be whole forward of OPTIONS request to target.
I have found solution using web filter https://stackoverflow.com/a/47494858/3523298
neede to add:
headers.add("Access-Control-Allow-Credentials", "true");
Most helpful comment
I have found solution using web filter https://stackoverflow.com/a/47494858/3523298