This guide explains how to set up and run the Safecast Tilemap project locally for development purposes.
Before you begin, make sure you have the following installed:
- Clone the repository or download the source code
- Navigate to the project directory
- Install the required npm packages:
npm installThis will install the necessary dependencies, including Express and http-proxy-middleware.
The Safecast Tilemap application requires two servers to run locally:
- A static file server to serve the HTML, CSS, and JavaScript files
- A proxy server to handle API requests to Safecast endpoints
Open a terminal window in the project directory and run:
python3 -m http.server 8000This starts a simple HTTP server on port 8000 that serves the static files from the current directory.
Open another terminal window in the project directory and run:
node proxy-server.jsThis starts the proxy server on port 8010 that handles API requests to:
- Safecast API (api.safecast.org)
- Realtime sensor data (tt.safecast.org)
- Tile server (S3 bucket)
Open your web browser and navigate to:
http://localhost:8000
The Safecast Tilemap should now be running locally with full functionality.
The proxy server (proxy-server.js) handles the following routes:
/api/*→ Proxies tohttps://api.safecast.org/tt-api/*→ Proxies tohttps://tt.safecast.org/s3-tiles/*→ Proxies tohttps://te512jp.safecast.org.s3-ap-northeast-1.amazonaws.com
This allows the frontend to make API calls without running into CORS issues.
- Make changes to the JavaScript files
- Refresh your browser to see the changes
- For changes to the proxy server, restart the Node.js server
- If you see CORS errors in the browser console, make sure the proxy server is running
- If the map doesn't load, check the browser console for errors related to the tile server
- If real-time sensors don't appear, check the console for errors related to the tt.safecast.org API