You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am trying to deliver a website with assets. The requirement is that everything except the assets is protected by authentication. I have therefore created two files sections, one with authentication, one without. Then I have chosen different base_path and document_root.
As a result, I get a 404 error for both / and /assets/icon.png.
Here is a screenshot of my folder structure and the relevant part of the couper config.
To Reproduce
Steps to reproduce the behavior:
Which Couper version? Run couper version or docker run coupergateway/couper version
1.12.1 2023-03-20 233f0d7
go version go1.19.6 darwin/amd64
Provide your configuration file *.hcl. Remove sensitive data.
Unfortunately the "htdocs" files handler is sorted before the "assets" files handler, and so is used even for requests to "/assets/icon.png".
If I add a path segment to the basepaths ("/files" and "/files/assets"), everything is as I'd expect ("longer" "/files/assets" wins against "shorter" "/files" when requesting "/files/assets/icon.png").
@malud Any idea why the sorting in server.SortPathPatterns() sorts "/"before"/a" (while sorting "/**"after"/a/**"), as in TestSortPathPatterns() (server/mux_test.go)?
BTW, in RegisterConfigured() (server/mux.go) the utils.JoinOpenAPIPath(path, "/**") for entries of m.opts.FileRoutes is done after sorting.
So I see two options:
change the sorting order OR
already add the wildcard to the path before passing it to setRoutesFromHosts() in (config/runtime/server.go)
If I have an additional api block (even empty, equivalent to base_path = "/"),
server {
files"htdocs" {
base_path="/"document_root="./htdocs"
}
files"assets" {
base_path="/assets"document_root="./assets"
}
api {
}
}
I can reproduce the 404 on http://localhost:8080/. That is, because the api block (with implicit base_path = "/") takes precedence over the files block (with explicit base_path = "/").
Describe the bug
I am trying to deliver a website with assets. The requirement is that everything except the assets is protected by authentication. I have therefore created two files sections, one with authentication, one without. Then I have chosen different base_path and document_root.
As a result, I get a 404 error for both / and /assets/icon.png.
Here is a screenshot of my folder structure and the relevant part of the couper config.
To Reproduce
Steps to reproduce the behavior:
couper version
ordocker run coupergateway/couper version
1.12.1 2023-03-20 233f0d7
go version go1.19.6 darwin/amd64
*.hcl
. Remove sensitive data.curl
call for reproductioncurl 'http://localhost:8080/'
Expected behavior
For / index.html is delivered from the htdocs folder, for /assets/icon.png the file icon.png is delivered from the assets folder.
The text was updated successfully, but these errors were encountered: