Skip to content
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Added all ports on localhost, 127.0.0.1 and 0.0.0.0 to CORS allowed origins.
### Changed
- Altered the `/api/recent_routes` endpoint to return routes from the last 24 hours. Previously it returned routes from the current calendar day.

Expand Down
10 changes: 9 additions & 1 deletion polarrouteserver/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ALLOWED_HOSTS = [
"localhost",
"0.0.0.0",
"127.0.0.1",
]
if os.getenv("POLARROUTE_ALLOWED_HOSTS", None) is not None:
ALLOWED_HOSTS.extend(os.getenv("POLARROUTE_ALLOWED_HOSTS").split(","))
Expand Down Expand Up @@ -96,10 +97,17 @@
"corsheaders",
]

CORS_ALLOWED_ORIGINS = ["http://localhost:8000"]
CORS_ALLOWED_ORIGINS = []
if os.getenv("POLARROUTE_CORS_ALLOWED_ORIGINS", None) is not None:
CORS_ALLOWED_ORIGINS.extend(os.getenv("POLARROUTE_CORS_ALLOWED_ORIGINS").split(","))

# Allow all localhost origins for CORS in development
CORS_ALLOWED_ORIGIN_REGEXES = [
r"^(?:https*:\/\/)*localhost:\d{2,4}$", # matches localhost with or without http(s):// and a port of 2-4 digits
r"^(?:https*:\/\/)*127.0.0.1:\d{2,4}$", # same for 127.0.0.1
r"^(?:https*:\/\/)*0.0.0.0:\d{2,4}$", # same for 0.0.0.0
]

CORS_ALLOW_METHODS = ("DELETE", "GET", "POST", "OPTIONS")

MIDDLEWARE = [
Expand Down
Loading