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
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,25 @@ to make ODIN use your on-premise instance of Nominatim you cat use the environme

You are an offline-first user and want to host your own map server (i.e. on your laptop)? GeoWebServer is way to big and uses too many resources? Just fire up [mbtileserver](https://github.com/consbio/mbtileserver), provide a _mbtile_ file that contains all your map tiles and you are done.

## Development

### Build hygiene

`npm start` runs the app against the prebuilt `dist/` directory — it does **not** build.
After an interrupted or partial webpack build, `dist/` can contain a bundle and a
source map that do not match each other. Opening the Chrome DevTools against such a
mismatched build freezes the renderer (the inspector blocks while trying to reconcile
bundle and source map).

If the app freezes when DevTools opens, do a clean build before starting:

```
rm -rf dist && npm run webpack && npm start
```

`npm run hot` (webpack-dev-server) is unaffected, since it always serves a consistent
in-memory build.

## License

Copyright (c) Syncpoint GmbH. All rights reserved.
Expand Down
101 changes: 61 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"babel-loader": "^10.0.0",
"c8": "^10.1.3",
"css-loader": "^7.1.2",
"electron": "^38.8.0",
"electron": "^42.2.0",
"electron-builder": "^26.7.0",
"electron-updater": "^6.1.4",
"eslint-config-standard": "^17.0.0",
Expand Down
13 changes: 11 additions & 2 deletions src/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,22 @@ const ready = async () => {

// Register app:// protocol handler to serve static files from dist/.
const distPath = path.join(app.getAppPath(), 'dist')
protocol.handle('app', (request) => {
protocol.handle('app', async (request) => {
const requestURL = new globalThis.URL(request.url)
const filePath = path.join(distPath, path.normalize(requestURL.pathname))
if (!filePath.startsWith(distPath)) {
return new Response('Forbidden', { status: 403 })
}
return net.fetch('file://' + filePath)

// The handler must always resolve to a Response. Returning a rejected
// net.fetch() promise (e.g. for a missing file) leaves the request
// unresolved, which freezes the renderer when DevTools requests source
// maps or webpack-virtual source paths that have no file on disk.
try {
return await net.fetch('file://' + filePath)
} catch {
return new Response('Not Found', { status: 404 })
}
})

// Inject Content-Security-Policy and augment CORS headers.
Expand Down
Loading