Skip to content

Commit 81cc92d

Browse files
committed
Fix Maps referrer for macOS app
1 parent 002a72c commit 81cc92d

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Create two API keys in Google Cloud:
4141
1. Browser key
4242
- Enable API: Maps JavaScript API
4343
- API restriction: Maps JavaScript API
44+
- If you use website restrictions, allow:
45+
- `http://127.0.0.1:5173/*`
46+
- `http://localhost:5173/*`
4447
- Store it as `VITE_GOOGLE_MAPS_API_KEY`
4548

4649
2. Metadata key
@@ -55,7 +58,7 @@ VITE_GOOGLE_MAPS_API_KEY=your_browser_key
5558
GOOGLE_STREET_VIEW_METADATA_API_KEY=your_metadata_key
5659
```
5760

58-
For the browser key, Google Maps JavaScript runs inside a macOS `WKWebView`. If you use website restrictions, allow local app origins such as `http://127.0.0.1/*`. If that is too strict for your Google Cloud setup, use API restrictions and keep the key private to your own Mac.
61+
For the browser key, Google Maps JavaScript runs inside a macOS `WKWebView` with a local base URL of `http://127.0.0.1:5173/`.
5962

6063
## Updates
6164

Sources/StreetViewWander/StreetViewWebView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct StreetViewWebView: NSViewRepresentable {
1616

1717
let webView = WKWebView(frame: .zero, configuration: configuration)
1818
webView.setValue(false, forKey: "drawsBackground")
19-
webView.loadHTMLString(Self.html, baseURL: URL(string: "http://127.0.0.1/"))
19+
webView.loadHTMLString(Self.html, baseURL: URL(string: "http://127.0.0.1:5173/"))
2020
context.coordinator.webView = webView
2121
return webView
2222
}

scripts/package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if [[ -z "$DEFAULT_REPOSITORY" ]]; then
2121
DEFAULT_REPOSITORY="kmg0308/streetview-wander"
2222
fi
2323

24-
DIST_DIR="$ROOT_DIR/dist"
24+
DIST_DIR="${DIST_DIR:-$ROOT_DIR/dist}"
2525
APP_DIR="$DIST_DIR/$APP_NAME.app"
2626

2727
cd "$ROOT_DIR"

0 commit comments

Comments
 (0)