TerriaJS-Server is a foundational Node.js Express server designed to complement the TerriaJS geospatial platform. It provides essential backend services for web-based 2D and 3D geospatial data explorers, including a robust CORS proxy for accessing data providers that lack proper CORS headers, a `proj4` Coordinate Reference System (CRS) lookup service, an `ogr2ogr` conversion service for unsupported geospatial vector data formats (like shapefiles) to GeoJSON, and services for persistent sharing of map configurations. Currently at stable version 4.0.4, published recently, the package undergoes active maintenance with updates driven by the needs of the broader TerriaJS ecosystem. Its key differentiators lie in its specialized geospatial services and deep integration with TerriaJS and TerriaMap, enabling rich, interactive mapping applications, particularly within the context of National Map projects.
npm install terriajs-serverVerified import paths — ran on the pinned version, not inferred.
Demonstrates programmatic initialization and startup of the TerriaJS Server with a basic configuration, including static file serving and environment variable usage for secrets. This is useful for embedding or custom deployments.
Upgrade your Node.js environment to version 20.x or 22.x. Check the `engines` field in `package.json` for the exact requirement.
Migrate your import statements to use ECMAScript Modules (ESM) syntax, e.g., `import { createTerriaServer } from 'terriajs-server';`.Remove PM2 from your deployment strategy for `terriajs-server`. Use native `node` commands, or container orchestration tools like Docker/Kubernetes directly. For development, `npm start` runs in the foreground.
Explicitly define all domains for which the proxy service should be active within your custom `serverconfig.json` file under the `allowProxyFor` array. Always review and update this configuration for security and functionality.
Upgrade `terriajs-server` to version 4.0.2 or higher to benefit from these crucial security fixes. Review your `allowProxyFor` configuration carefully to prevent unintended proxying.
Change your import statement to use ESM syntax: `import { createTerriaServer } from 'terriajs-server';` or `import createTerriaServer from 'terriajs-server';` if it's a default export.Copy `serverconfig.json.example` (or `devserverconfig.json`) from the package's root or documentation to `serverconfig.json` in your project's root and configure it according to your needs. Ensure the server has read access to this file.
Edit your `serverconfig.json` file and add the domain of the problematic resource to the `allowProxyFor` array. Ensure the URL scheme (HTTP/HTTPS) and domain exactly match.
Change the `port` in your `serverconfig.json` or pass the `--port` option when starting the server (e.g., `npm start -- --port 8000`) to use an available port. Kill the conflicting process if it's unintentional.