Skip to content

Commit

Permalink
change env var name so it's never sent to the client bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Woozl committed Jun 15, 2023
1 parent 8dfc53b commit ed2ae92
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the
In order to get data from the Strapi server at `api.renci.org`, you need to provide an API token as an environment variable to be used in the request `Authorization` header. For development, create a `.env` file in the root of the project.

```env
NEXT_PUBLIC_ACCESS_TOKEN=YOUR_API_TOKEN
STRAPI_ACCESS_TOKEN=YOUR_API_TOKEN
```

## Deployment
Expand All @@ -22,7 +22,7 @@ This project contains a [Github Action workflow](./.github/workflows/build-image
The GH action uses a [robot account token](https://goharbor.io/docs/1.10/working-with-projects/project-configuration/create-robot-accounts/) with permissions to create artifacts and tags. If you modify or update this account in Harbor, make sure to change the `USER` and `PW` in the Github secrets settings.

### Strapi API access token
For the deployed environment, the `NEXT_PUBLIC_ACCESS_TOKEN` environment variable is provided to the Next.JS container using a Secret called `renci-dot-org-api`, which has one variable called `token`. You can check if a secret already exists:
For the deployed environment, the `ACCESS_TOKEN` environment variable is provided to the Next.JS container using a Secret called `renci-dot-org-api`, which has one variable called `token`. You can check if a secret already exists:

```bash
kubectl get secrets -n YOUR_NAMESPACE_HERE
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ image:
tag: latest

env:
- name: NEXT_PUBLIC_ACCESS_TOKEN
- name: STRAPI_ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: renci-dot-org-api
Expand Down
2 changes: 1 addition & 1 deletion lib/strapi/fetchStrapiGraphQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const fetchStrapiGraphQL = async (query, preview = false) => {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.NEXT_PUBLIC_ACCESS_TOKEN}`,
Authorization: `Bearer ${process.env.STRAPI_ACCESS_TOKEN}`,
},
body: JSON.stringify({ query }),
}).then((response) => response.json());
Expand Down
2 changes: 1 addition & 1 deletion utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function fetchAPI(path, options = {}) {
headers: {
"Content-Type": "application/json",
Authorization:
`Bearer ${process.env.NEXT_PUBLIC_ACCESS_TOKEN}`,
`Bearer ${process.env.STRAPI_ACCESS_TOKEN}`,
},
};
const mergedOptions = {
Expand Down

0 comments on commit ed2ae92

Please sign in to comment.