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

better handle URL path when app if proxied #166

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,5 @@ cdk.out/
.pgdata/
docs/src/api/*

traefik.toml
routes.toml
9 changes: 8 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

Note: Minor version `0.X.0` update might break the API, It's recommended to pin `tipg` to minor version: `tipg>=0.1,<0.2`

## [0.6.2] - 2024-01-19

- add `root_path` API settings
- fix invalid `url` parsing in HTML responses

## [0.6.1] - 2024-01-11

- use `spatial_extent` and `datetime_extent` configuration options in `CatalogUpdateMiddleware` and `/refresh` endpoint (author @hrodmn, https://github.com/developmentseed/tipg/pull/164)
Expand Down Expand Up @@ -276,7 +281,9 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin

- Initial release

[unreleased]: https://github.com/developmentseed/tipg/compare/0.6.0...HEAD
[unreleased]: https://github.com/developmentseed/tipg/compare/0.6.2...HEAD
[0.6.2]: https://github.com/developmentseed/tipg/compare/0.6.1...0.6.2
[0.6.1]: https://github.com/developmentseed/tipg/compare/0.6.0...0.6.1
[0.6.0]: https://github.com/developmentseed/tipg/compare/0.5.7...0.6.0
[0.5.8]: https://github.com/developmentseed/tipg/compare/0.5.7...0.5.8
[0.5.7]: https://github.com/developmentseed/tipg/compare/0.5.6...0.5.7
Expand Down
4 changes: 4 additions & 0 deletions tipg/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import abc
import csv
import json
import re
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, Generator, Iterable, List, Literal, Optional
from urllib.parse import urlencode
Expand Down Expand Up @@ -119,6 +120,9 @@ def create_html_response(
) -> _TemplateResponse:
"""Create Template response."""
urlpath = request.url.path
if root_path := request.app.root_path:
urlpath = re.sub(r"^" + root_path, "", urlpath)

crumbs = []
baseurl = str(request.base_url).rstrip("/")

Expand Down
1 change: 1 addition & 0 deletions tipg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ async def lifespan(app: FastAPI):
openapi_url="/api",
docs_url="/api.html",
lifespan=lifespan,
root_path=settings.root_path,
)

# custom template directory
Expand Down
1 change: 1 addition & 0 deletions tipg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class APISettings(BaseSettings):
cors_origins: str = "*"
cachecontrol: str = "public, max-age=3600"
template_directory: Optional[str] = None
root_path: str = ""

add_tiles_viewer: bool = True

Expand Down
Loading