Skip to content

bug: enable both http_to_https and append_query_string of the redirect plugin will cause the query string to be repeated twice #7394

Description

@nic-6443

Current Behavior

curl --location --request PUT 'http://apisix-admin:9180/apisix/admin/routes/redirect' \
--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
--header 'Content-Type: application/json' \
--data-raw '{
    "host": "redirect",
    "uri": "/*",
    "upstream": {
        "type": "roundrobin",
        "nodes": [
            {
                "host": "httpbin",
                "port": 80,
                "weight": 1
            }
        ]
    },
    "plugins": {
        "redirect": {
            "http_to_https": true,
            "append_query_string": true
        }
    },
    "name": "redirect"
}'
❯ curl --noproxy '*' http://apisix-gateway/ip\?hello\=world -H "Host: redirect" -v
*   Trying 10.98.108.144:80...
* TCP_NODELAY set
* Connected to apisix-gateway (10.98.108.144) port 80 (#0)
> GET /ip?hello=world HTTP/1.1
> Host: redirect
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Date: Wed, 06 Jul 2022 08:21:16 GMT
< Content-Type: text/html
< Content-Length: 166
< Connection: keep-alive
< Location: https://redirect/ip?hello=world&hello=world
< Server: APISIX/2.13.1
< 
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
* Connection #0 to host apisix-gateway left intact

Expected Behavior

Tell the user in the documentation not to use both http_to_https and append_query_string options, or that apisix automatically handles not repeating the query string when both options are configured at the same time

Error Logs

No response

Steps to Reproduce

/

Environment

  • APISIX version (run apisix version): 2.13.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions