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

Inclusion of root-path prefix in paths available from service-desc when hosted behind a proxy #497

Open
jfbourgon opened this issue Nov 23, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@jfbourgon
Copy link

Current and expected behavior
As discussed in #489, when STAC-fastapi is hosted behind a proxy and started with a command like the following:

uvicorn --root-path "/stac" --proxy-headers stac_fastapi.sqlalchemy.app:app

All the links rendered by the application are the ones expected and they can be used to reach the various endpoints supported by the application. The only notable exception is inside the service-desc located under /stac/api, this endpoint is reachable but its content provides broken links since none of them include the expected root-path prefix (/stac in our specific case).

Current

{
	"openapi": "3.0.2",
	"info": {
		"title": "stac-fastapi",
		"version": "0.1"
	},
	"paths": {
		"/": {
			"get": {
				"summary": "Landing Page",
				"description": "Endpoint.",
				"operationId": "Landing_Page__get",
				"responses": {
					"200": {
						"description": "Successful Response",
						"content": {
							"application/json": {
								"schema": {}
							}
						}
					}
				}
			}
		},
		"/conformance": {
			"get": {
				"summary": "Conformance Classes",
				"description": "Endpoint.",
				"operationId": "Conformance_Classes_conformance_get",
				"responses": {
					"200": {
						"description": "Successful Response",
						"content": {
							"application/json": {
								"schema": {}
							}
						}
					}
				}
			}
		},
		"/collections/{collection_id}/items/{item_id}": {
			"get": {
				"summary": "Get Item",
				"description": "Endpoint.",
				"operationId": "Get_Item_collections__collection_id__items__item_id__get",
				"parameters": [
...

Expected

{
	"openapi": "3.0.2",
	"info": {
		"title": "stac-fastapi",
		"version": "0.1"
	},
	"paths": {
		"/stac/": {
			"get": {
				"summary": "Landing Page",
				"description": "Endpoint.",
				"operationId": "Landing_Page__get",
				"responses": {
					"200": {
						"description": "Successful Response",
						"content": {
							"application/json": {
								"schema": {}
							}
						}
					}
				}
			}
		},
		"/stac/conformance": {
			"get": {
				"summary": "Conformance Classes",
				"description": "Endpoint.",
				"operationId": "Conformance_Classes_conformance_get",
				"responses": {
					"200": {
						"description": "Successful Response",
						"content": {
							"application/json": {
								"schema": {}
							}
						}
					}
				}
			}
		},
		"/stac/collections/{collection_id}/items/{item_id}": {
			"get": {
				"summary": "Get Item",
				"description": "Endpoint.",
				"operationId": "Get_Item_collections__collection_id__items__item_id__get",
				"parameters": [
...

The omission of the root-path prefix makes all the potential interactions with the API available inside the api.html page with Try it out buttons unusable as it returns 404 errors.

The issue can be worked around by creating a custom StacApi class as illustrated here https://github.com/microsoft/planetary-computer-apis/blob/main/pcstac/pcstac/api.py#L22-L26, but as running behind a proxy could be a common use case for many deployments, it might make sense to pull this feature directly into stac-fastapi.

@gadomski gadomski added the enhancement New feature or request label Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants