Node/Express Backend
This backend example keeps the PlaceField secret key on the server and exposes a local /api/locations/autocomplete route for your app.
Run Locally
cd examples/node-express npm install npm run dev
Open http://localhost:3000/.
Configure The Key
Replace the placeholder in placefield.config.json when you want real PlaceField results:
{
"placeField": {
"secretKey": "pf_live_xxx",
"autocompleteUrl": "https://api.placefield.dev/v1/locations/autocomplete"
},
"server": {
"port": 3000
}
}
What The Server Does
- Validates
qbefore calling PlaceField. - Forwards only known autocomplete parameters.
- Sends
Authorization: Bearer pf_live_xxxfrom the backend. - Passes through PlaceField status codes, JSON,
Retry-After, and API version headers.
This static guide does not call the PlaceField API. Clone the repo and run the server locally to test with your key.