Skip to content

Fix: 403 error in map export#535

Merged
kshitijrajsharma merged 2 commits intomainfrom
feature/fix-403-error
Mar 18, 2026
Merged

Fix: 403 error in map export#535
kshitijrajsharma merged 2 commits intomainfrom
feature/fix-403-error

Conversation

@andrea-chirillano
Copy link
Copy Markdown
Collaborator

@andrea-chirillano andrea-chirillano commented Mar 18, 2026

Fixes HTTP 403 errors affecting map tile loading and export creation.

Root cause: Django's SecurityMiddleware was stripping the Referer header on cross-origin requests (default same-origin policy), and the browser was sending an Origin header on tile requests — both of which OSM tile servers reject with 403. Additionally, SessionAuthentication in DRF was causing CSRF-based 403s on API requests.

Changes:

Sets SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin" so the Referer header is preserved on cross-origin requests, satisfying OSM's tile policy.
Adds crossOrigin: null to the OSM tile layer to prevent the browser from sending an Origin header on tile requests.
Removes SessionAuthentication from DRF's authentication classes to eliminate CSRF-based 403s.

@kshitijrajsharma
Copy link
Copy Markdown
Member

Thanks @andrea-chirillano For your contribution !

@kshitijrajsharma kshitijrajsharma merged commit ea5c943 into main Mar 18, 2026
1 check passed
@andrea-chirillano andrea-chirillano deleted the feature/fix-403-error branch March 18, 2026 16:19
kshitijrajsharma added a commit that referenced this pull request Mar 18, 2026
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

Successfully merging this pull request may close these issues.

2 participants