Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next, prev and self links returned from /search endpoint ignore root_path settings #194

Open
Kirill888 opened this issue Jan 27, 2025 · 0 comments

Comments

@Kirill888
Copy link

This is on main branch.

When App is configured with a prefix, in our case /stac

app = FastAPI(root_path="/stac", lifespan=lifespan)

and we use search in POST mode with something like this:

DATA='{"datetime":"2021-01-01T00:00:00Z/2021-02-28T23:59:59Z","collections":["agera5"]}'
curl -v -s \
  -H 'Origin: https://somesite.org' \
  -H 'Content-Type: application/json' \
  -X POST -d "$DATA" \
  "https://XXXX.lambda-url.eu-central-1.on.aws/stac/search" | tee response.json | jq '.links'

Links for next and self returned from that endpoint are missing configured root_path prefix.

"links:" [
  {
    "rel": "next",
    "type": "application/geo+json",
    "method": "POST",
    "href": "https://XXXX.lambda-url.eu-central-1.on.aws/search",
    "body": {
      "datetime": "2021-01-01T00:00:00Z/2021-02-28T23:59:59Z",
      "collections": [
        "agera5"
      ],
      "token": "next:agera5:agera5-20210219"
    }
  },
  {
    "rel": "root",
    "type": "application/json",
    "href": "https://XXXX.lambda-url.eu-central-1.on.aws/stac/"
  },
  {
    "rel": "self",
    "type": "application/json",
    "href": "https://XXXX.lambda-url.eu-central-1.on.aws/search"
  }
]

Note that root link is correct in the response above, so configuration is being picked up.

My guess that error is here:

if method == "POST":
return {
"rel": Relations.next,
"type": MimeTypes.geojson,
"method": method,
"href": f"{self.request.url}",
"body": {**self.request.postbody, "token": f"next:{self.next}"},
}

Raw request.url is used without calling self.resolve(..) to patch it for external view of the API endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant