rogerogers edited a comment on issue #3407:
URL: https://github.com/apache/apisix/issues/3407#issuecomment-767254734


   > For the "sometimes" problem, you should add more log in the cors plugin, 
to see what happened when the error occurs.
   > For example:
   > 
https://github.com/apache/apisix/blob/8904011fa8321358b7fb31f612cca887fa23ff28/apisix/plugins/cors.lua#L168
   > 
   > 
   > You should log down the `ctx.conf_type`, `ctx.conf_id` and returned 
`multiple_origin`.
   
   ### code
   * <pre>local multiple_origin, err = core.lrucache.plugin_ctx(lrucache, ctx, 
nil,
                                                   
create_multiple_origin_cache, conf)
     local json=require('cjson.safe')
     core.log.error(json.encode(multiple_origin))
   </pre>
   
   * <pre>local allow_methods = conf.allow_methods
     core.log.error(conf.allow_methods.. 'guess')
     if allow_methods == "**" then
         allow_methods = "GET,POST,PUT,DELETE,PATCH,HEAD,OPTIONS,CONNECT,TRACE"
     end
     core.response.set_header("Access-Control-Allow-Origin", 
ctx.cors_allow_origins)
     core.log.error(ctx.cors_allow_origins)
   </pre>
   
   ### logs
   * 2021/01/26 10:30:38 [error] 3816274#3816274: *1473 [lua] cors.lua:173: 
phase_func(): 
{"http:\/\/m-local.guess.com":true,"http:\/\/www-local.guess.com":true} while 
reading response header from upstream, client: 127.0.0.1, server: , request: 
"POST /products/comments HTTP/1.0", upstream: 
"http://127.0.0.1:9505/products/comments";, host: "api-local.guess.com", 
referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:38 [error] 3816274#3816274: *1473 [lua] cors.lua:131: 
set_cors_headers(): GET,POST,OPTIONSguess while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/comments 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/comments";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail";
   2021/01/26 10:30:38 [error] 3816274#3816274: *1473 [lua] cors.lua:137: 
set_cors_headers(): http://m-local.guess.com while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/comments 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/comments";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail";
   2021/01/26 10:30:38 [error] 3816273#3816273: *1469 [lua] cors.lua:173: 
phase_func(): 
{"http:\/\/www-local.guess.com":true,"http:\/\/m-local.guess.com":true} while 
reading response header from upstream, client: 127.0.0.1, server: , request: 
"POST /products/v3/detail HTTP/1.0", upstream: 
"http://127.0.0.1:9505/products/v3/detail";, host: "api-local.guess.com", 
referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:38 [error] 3816273#3816273: *1469 [lua] cors.lua:131: 
set_cors_headers(): GET,POST,OPTIONSguess while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/v3/detail 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/v3/detail";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail";
   2021/01/26 10:30:38 [error] 3816273#3816273: *1469 [lua] cors.lua:137: 
set_cors_headers(): http://m-local.guess.com while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/v3/detail 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/v3/detail";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:38 [error] 3816273#3816273: *1538 [lua] cors.lua:173: 
phase_func(): 
{"http:\/\/www-local.guess.com":true,"http:\/\/m-local.guess.com":true}, 
client: 127.0.0.1, server: , request: "OPTIONS /products/recommend HTTP/1.0", 
host: "api-local.guess.com", referrer: "http://m-local.guess.com/detail";
   2021/01/26 10:30:38 [error] 3816273#3816273: *1538 [lua] cors.lua:131: 
set_cors_headers(): GET,POST,OPTIONSguess, client: 127.0.0.1, server: , 
request: "OPTIONS /products/recommend HTTP/1.0", host: "api-local.guess.com", 
referrer: "http://m-local.guess.com/detail";
   2021/01/26 10:30:38 [error] 3816273#3816273: *1538 [lua] cors.lua:137: 
set_cors_headers(): http://m-local.guess.com, client: 127.0.0.1, server: , 
request: "OPTIONS /products/recommend HTTP/1.0", host: "api-local.guess.com", 
referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:39 [error] 3816276#3816276: *1540 [lua] cors.lua:173: 
phase_func(): 
{"http:\/\/m-local.guess.com":true,"http:\/\/www-local.guess.com":true} while 
reading response header from upstream, client: 127.0.0.1, server: , request: 
"POST /products/recommend HTTP/1.0", upstream: 
"http://127.0.0.1:9505/products/recommend";, host: "api-local.guess.com", 
referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:39 [error] 3816276#3816276: *1540 [lua] cors.lua:131: 
set_cors_headers(): GET,POST,OPTIONSguess while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/recommend 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/recommend";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail";
   2021/01/26 10:30:39 [error] 3816276#3816276: *1540 [lua] cors.lua:137: 
set_cors_headers(): http://m-local.guess.com while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/recommend 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/recommend";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail";
   
   * 2021/01/26 10:30:42 [error] 3816275#3816275: *1750 [lua] cors.lua:173: 
phase_func(): 
{"http:\/\/m-local.guess.com":true,"http:\/\/www-local.guess.com":true} while 
reading response header from upstream, client: 127.0.0.1, server: , request: 
"POST /products/v3/detail HTTP/1.0", upstream: 
"http://127.0.0.1:9505/products/v3/detail";, host: "api-local.guess.com", 
referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:42 [error] 3816275#3816275: *1750 [lua] cors.lua:131: 
set_cors_headers(): GET,POST,OPTIONSguess while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/v3/detail 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/v3/detail";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail";
   2021/01/26 10:30:42 [error] 3816275#3816275: *1750 [lua] cors.lua:137: 
set_cors_headers(): http://m-local.guess.com while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/v3/detail 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/v3/detail";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail";
   2021/01/26 10:30:42 [error] 3816275#3816275: *1750 [lua] cors.lua:173: 
phase_func(): 
{"http:\/\/m-local.guess.com":true,"http:\/\/www-local.guess.com":true} while 
reading response header from upstream, client: 127.0.0.1, server: , request: 
"POST /products/v3/detail HTTP/1.0", upstream: 
"http://127.0.0.1:9505/products/v3/detail";, host: "api-local.guess.com", 
referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:42 [error] 3816275#3816275: *1750 [lua] cors.lua:131: 
set_cors_headers(): GET,POST,OPTIONSguess while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/v3/detail 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/v3/detail";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail";
   2021/01/26 10:30:42 [error] 3816275#3816275: *1750 [lua] cors.lua:137: 
set_cors_headers(): http://m-local.guess.com while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/v3/detail 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/v3/detail";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:43 [error] 3816275#3816275: *1805 [lua] cors.lua:173: 
phase_func(): 
{"http:\/\/m-local.guess.com":true,"http:\/\/www-local.guess.com":true} while 
reading response header from upstream, client: 127.0.0.1, server: , request: 
"POST /products/recommend HTTP/1.0", upstream: 
"http://127.0.0.1:9505/products/recommend";, host: "api-local.guess.com", 
referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:43 [error] 3816275#3816275: *1805 [lua] cors.lua:131: 
set_cors_headers(): GET,POST,OPTIONSguess while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/recommend 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/recommend";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail/";
   2021/01/26 10:30:43 [error] 3816275#3816275: *1805 [lua] cors.lua:137: 
set_cors_headers(): http://m-local.guess.com while reading response header from 
upstream, client: 127.0.0.1, server: , request: "POST /products/recommend 
HTTP/1.0", upstream: "http://127.0.0.1:9505/products/recommend";, host: 
"api-local.guess.com", referrer: "http://m-local.guess.com/detail/";
   
   Seems no log when situation occurred


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to