added token loading from env vars

This commit is contained in:
Samuel Andert 2023-08-22 10:34:27 +02:00
parent c7a8449863
commit 17921cf221
3 changed files with 12 additions and 11 deletions

View File

@ -16,10 +16,10 @@ sources:
source: schemas/directus.graphql
operationHeaders:
Authorization: Bearer {env.DIRECTUS_API}
# - name: Cloudron
# handler:
# openapi:
# endpoint: https://my.andert.me/api/v1
# source: schemas/cloudron.json
# operationHeaders:
# Authorization: Bearer {env.CLOUDRON_API}
- name: Cloudron
handler:
openapi:
endpoint: https://my.andert.me/api/v1
source: schemas/cloudron.json
operationHeaders:
Authorization: Bearer {env.CLOUDRON_API}

View File

@ -3,7 +3,9 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "mesh build && next dev",
"mesh:dev": "dotenv -e .env.local -- mesh build",
"next:dev": "dotenv -e .env.local -- next dev",
"dev": "npm run mesh:dev && npm run next:dev",
"schema": "dotenv -- node ./src/fetch-schema.js",
"build": "mesh build && next build",
"start": "next start",

View File

@ -7,12 +7,11 @@ type UserType = {
const resolveUserFn = async context => {
const authHeader = context.req.headers.authorization;
if (authHeader !== "token123") {
const authtoken = process.env.GRAPHQL_MESH
if (authHeader !== authtoken) {
console.error('Failed to validate token')
return null
}
// If the token is valid, return the user
// Replace this with your actual user fetching logic
return { id: 'user1' };
}