Skip to content

Commit

Permalink
[DOC] Document NB_QUERY_HEADER_SCRIPT (#468)
Browse files Browse the repository at this point in the history
* [DOC] Document NB_QUERY_HEADER_SCRIPT

* [FIX] Update default for client ID ENV var

* Give an example for how to include a script
  • Loading branch information
surchs authored Feb 2, 2025
1 parent 50e9549 commit ab5b1ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ but before proceeding with either you need to set the environment variables.
| `NB_API_QUERY_URL` | string | Yes | - | `https://federate.neurobagel.org/` |
| `NB_QUERY_APP_BASE_PATH` | string | No | `/` | `/query/` |
| `NB_ENABLE_AUTH` | boolean | No | `false` | `false` |
| `NB_QUERY_CLIENT_ID` | string | Yes (if `NB_ENABLE_AUTH` is set to true) | - | `46923719231972-dhsahgasl3123.apps.googleusercontent.com` |
| `NB_QUERY_CLIENT_ID` | string | Yes (if `NB_ENABLE_AUTH` is set to true) | - | `""` |
| `NB_QUERY_HEADER_SCRIPT` | string | No | `""` | `'<script defer data-domain="mydomain" src="plausible">'` |

#### `NB_API_QUERY_URL`

Expand All @@ -64,6 +65,17 @@ If the API you'd like to send queries to requires authentication, you need to se
If the `NB_ENABLE_AUTH` is set to `true` (it is `false` by default), you need to provide a valid client ID for the authentication.
_At the moment, query tool uses Google for authentication, so you need to obtain a client ID from Google developer console. See [documentation](https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid) for more information._

#### `NB_QUERY_HEADER_SCRIPT`

If you want to add a custom script to the header of the query tool, you can set the `NB_QUERY_HEADER_SCRIPT` environment variable to the script you want to add.
This script will be added to the header of the query tool. For example, in our production deployment we use the GDPR aware analytics tool [Plausible](https://plausible.io/),
so we set the `NB_QUERY_HEADER_SCRIPT` to the script provided by Plausible.
When you use this variable, make sure you use single quotes to include the script like so:

```bash
NB_QUERY_HEADER_SCRIPT='<script defer data-domain="mydomain" src="plausible">'
```

#### Set the environment variables

To set environment variables, create a `.env` file in the root directory and add the environment variables there. If you're running a neurobagel node-API locally on your machine (following the instructions [here](https://github.com/neurobagel/api#local-installation)), your `.env` file would look something like this:
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
for file in $(find /usr/share/nginx/html -type f \( -name "*.js" -o -name "*.html" \)); do
sed -i "s|REPLACE_ME_NB_API_QUERY_URL_REPLACE_ME|${NB_API_QUERY_URL}|g" "$file"
sed -i "s|REPLACE_ME_NB_ENABLE_AUTH_REPLACE_ME|${NB_ENABLE_AUTH:-false}|g" "$file"
sed -i "s|REPLACE_ME_NB_QUERY_CLIENT_ID_REPLACE_ME|${NB_QUERY_CLIENT_ID:-testclient1234}|g" "$file"
sed -i "s|REPLACE_ME_NB_QUERY_CLIENT_ID_REPLACE_ME|${NB_QUERY_CLIENT_ID}|g" "$file"
sed -i "s|REPLACE_ME_NB_ENABLE_CHATBOT_REPLACE_ME|${NB_ENABLE_CHATBOT:-false}|g" "$file"
sed -i "s|REPLACE_ME_NB_QUERY_APP_BASE_PATH_REPLACE_ME|${NB_QUERY_APP_BASE_PATH:-/}|g" "$file"
sed -i "s|<!-- REPLACE_ME_NB_QUERY_HEADER_SCRIPT_REPLACE_ME -->|${NB_QUERY_HEADER_SCRIPT}|g" "$file"
Expand Down

0 comments on commit ab5b1ea

Please sign in to comment.