Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix(web): add required headers for Nominatim reverse geocoding API

Steven89b0b81bdcc8
diff --git a/web/src/components/MemoEditor/ActionButton/InsertMenu.tsx b/web/src/components/MemoEditor/ActionButton/InsertMenu.tsx
index 39cee89fc..69975eccf 100644
--- a/web/src/components/MemoEditor/ActionButton/InsertMenu.tsx
+++ b/web/src/components/MemoEditor/ActionButton/InsertMenu.tsx
@@ -78,8 +78,18 @@ const InsertMenu = observer((props: Props) => {
const handlePositionChange = (position: LatLng) => {
location.handlePositionChange(position);
- fetch(`https://nominatim.openstreetmap.org/reverse?lat=${position.lat}&lon=${position.lng}&format=json`)
- .then((response) => response.json())
+ fetch(`https://nominatim.openstreetmap.org/reverse?lat=${position.lat}&lon=${position.lng}&format=json`, {
+ headers: {
+ "User-Agent": "Memos/1.0 (https://github.com/usememos/memos)",
+ Accept: "application/json",
+ },
+ })
+ .then((response) => {
+ if (!response.ok) {
+ throw new Error(`HTTP error! status: ${response.status}`);
+ }
+ return response.json();
+ })
.then((data) => {
if (data?.display_name) {
location.setPlaceholder(data.display_name);