Skip to content

Commit

Permalink
Include the query strings when redirecting requests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioluz committed Nov 7, 2023
1 parent c20c3e5 commit 1d7fef7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Scarf/Gateway/Rule/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ redirectOrProxy request domain !capture ResponseBuilder {..}
| shouldRedirectDockerRequest request =
-- As with the Host header we have to respect the proxy protocol
-- when redirecting.
let !absoluteUrl = "https://" <> domain <> Wai.rawPathInfo request
let !absoluteUrl = "https://" <> domain <> Wai.rawPathInfo request <> Wai.rawQueryString request
in redirectTo capture absoluteUrl
| otherwise =
proxyTo (const capture) domain
Expand Down
Empty file.
9 changes: 9 additions & 0 deletions test/golden/docker-test-2.output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"capture": "DockerCapture {dockerCaptureImage = [\"library\",\"proxy\"], dockerCaptureReference = \"list\", dockerCaptureBackendRegistry = \"ghcr.io\", dockerCapturePackage = Just \"8717953c-3452-4ef7-9a14-b64dc19163b4\", dockerCaptureAutoCreate = Nothing}",
"headers": {
"Location": "https://ghcr.io/v2/library/proxy/tags/list",
"X-This-Request-Was-Proxied": "1"
},
"query": "?n=10",
"status": 307
}
10 changes: 10 additions & 0 deletions test/golden/docker-test-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
path: /v2/library/proxy/tags/list?n=10
headers:
Host: cr.test.io
manifest:
rules:
- type: docker-v1
repository-name: library/proxy
domain: cr.test.io
registry: ghcr.io
package-id: "8717953c-3452-4ef7-9a14-b64dc19163b4"

0 comments on commit 1d7fef7

Please sign in to comment.