Skip to content

Fix OSM 403: inject Referer and User-Agent for tile requests#2630

Open
sensei-hacker wants to merge 1 commit into
iNavFlight:maintenance-9.xfrom
sensei-hacker:fix/osm-403-tile-referer
Open

Fix OSM 403: inject Referer and User-Agent for tile requests#2630
sensei-hacker wants to merge 1 commit into
iNavFlight:maintenance-9.xfrom
sensei-hacker:fix/osm-403-tile-referer

Conversation

@sensei-hacker
Copy link
Copy Markdown
Member

Summary

Fixes 403 errors from the OSM tile CDN when loading the map tab.

Electron provides no valid Referer for outgoing tile requests — packaged builds load pages from file://, and dev builds load from http://localhost. OSM's CDN rejects both with 403. The fix registers a webRequest.onBeforeSendHeaders hook on the default session at app startup that injects the required Referer and User-Agent headers on all requests to tile.openstreetmap.org.

Changes

  • js/main/main.js: import session from electron; register onBeforeSendHeaders hook in app.on('ready', ...) (not inside createWindow(), to prevent double-registration) that injects Referer and a policy-compliant User-Agent for OSM tile requests
  • URL filter covers both https://tile.openstreetmap.org/* (the URL OpenLayers actually uses) and https://*.tile.openstreetmap.org/* (CDN subdomain form)
  • User-Agent uses app.getVersion() so it tracks the package version dynamically rather than a hardcoded string

Testing

  • Launched configurator in dev mode, opened map tab — OSM tiles load without 403 errors
  • Confirmed tiles were previously failing before this change

Notes

Cherry-picked and amended from MartinovEm's PR #2599 (dff32ce). The original commit hardcoded the version string and used only the subdomain wildcard pattern; both issues are fixed here.

@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@sonarqubecloud
Copy link
Copy Markdown

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