Configuring the server
The configuration is in the .env file, at the root of the application. It contains secrets: restrict its permissions to the account that runs the server, and never send it by e-mail once filled in.
Steps
- Copy the
.env.exampletemplate to.env. - Fill in all values marked [OBLIGATOIRE] (required). Values marked [FACULTATIF] (optional) can stay empty: the default value then applies.
- Declare each target system (see below).
- Restart the server and read its logs: a missing or invalid value is reported there, and the server refuses to start if it is essential.
The full list of variables is in .env variables.
Server settings
| Variable | Value |
|---|---|
NODE_ENV | production on a real server. |
SERVER_PROTOCOL | https if the server handles its certificate, http behind a proxy (see Behind an HTTPS proxy). |
SERVER_PORT | Listening port (4999 by default). |
TLS_KEY_FILE, TLS_CERT_FILE | In https mode: private key and certificate (followed by the intermediate certificates), in PEM format. |
LOG_LEVEL | info recommended: sign-ins, uploads and startup are logged. |
Keys and redirect URI
| Variable | Value |
|---|---|
OAUTH_CALLBACK_URI | Public address of the server followed by /auth/callback, for example https://save2erp.my-company.com/auth/callback. It must be registered identically in the target system's OAuth2 client. |
OAUTH_COOKIE_CRYPTO_KEY | Token encryption key: 32 bytes encoded in base64. |
OAUTH_COOKIE_SIGN_KEY | Cookie signing key: another random value. Changing it signs out all users. |
To generate each key, on a computer where Node.js is installed:
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"Declaring a target system
Only the systems declared in .env are allowed: a document linked to another system is refused with "Unknown system". To forbid a system, delete its block.
The prefix of the variables gives the type of the system. Today, the only available type is SAP: its variables start with SAP_, followed by the system name as it appears in the S2E_SystemKey property of the documents (see Preparing Word documents).
SAP_P01CLNT100_ENV=PROD # SBX, DEV, QUAL or PROD: color of the pane
SAP_P01CLNT100_SID=P01
SAP_P01CLNT100_MANDT=100
SAP_P01CLNT100_APIBASE=https://sap.my-company.com:44300/rest
SAP_P01CLNT100_OAUTH_SERVER=https://sap.my-company.com:44300
SAP_P01CLNT100_OAUTH_CLIENT_ID=...
SAP_P01CLNT100_OAUTH_CLIENT_SECRET=...The OAuth2 scope is shared by all systems (SAP_OAUTH_SCOPE), unless a system has its own (SAP_P01CLNT100_OAUTH_SCOPE). The information to request from the SAP team is detailed in Target system: SAP.
At startup, the logs show each system's environment, or the reason why it is refused: missing variable, unknown environment, invalid path…
REST service paths
The server calls three services, whose paths are appended to APIBASE: upload (/attachments by default), check before upload (/attachments/check) and connection test (/attachments/healthcheck). For designer mode, it also calls, if the target system provides them, the user permissions (/attachments/permissions, variable SAP_PERMISSIONS_PATH) and the templates (/attachments/readTemplateXml, variable SAP_TEMPLATE_PATH). If your target system uses other paths:
# All systems of the installation
SAP_ATTACHMENTS_PATH=/v1/document/attachments
SAP_CHECK_PATH=/v1/document/check
SAP_HEALTHCHECK_PATH=/v1/document/healthcheck
# Exception for one system
SAP_Q01CLNT100_HEALTHCHECK_PATH=/attachment/healthcheck/version/1/A path starts with / and contains no //, ?, # or space. An invalid path makes the system unusable.
Pane color and icon
The color of the pane depends on the system's environment (_ENV):
| Environment | Button color |
|---|---|
| SBX | purple |
| DEV | ochre |
| QUAL | green |
| PROD | navy blue |
You can choose another color for a system, in #RRGGBB format, in quotes (an unquoted # starts a comment):
SAP_P01CLNT100_COLOR="#0f6a99"The page background and the hover color are derived from it. Choose a color dark enough for the white text of the buttons to remain readable (contrast of at least 4.5:1 with white), and avoid red, which is reserved for errors.
The icon at the top of the pane can also be replaced, for all systems (SAP_ICON) or for one (SAP_P01CLNT100_ICON): .svg or .png file, absolute path or relative to the application folder. A missing file or a file in another format makes the system unusable.
Applying a change
The .env file is read at startup: restart the server after each change (with Docker: docker compose restart), then check the logs.