added token loading from env vars
This commit is contained in:
parent
c7a8449863
commit
17921cf221
14
.meshrc.yml
14
.meshrc.yml
@ -16,10 +16,10 @@ sources:
|
|||||||
source: schemas/directus.graphql
|
source: schemas/directus.graphql
|
||||||
operationHeaders:
|
operationHeaders:
|
||||||
Authorization: Bearer {env.DIRECTUS_API}
|
Authorization: Bearer {env.DIRECTUS_API}
|
||||||
# - name: Cloudron
|
- name: Cloudron
|
||||||
# handler:
|
handler:
|
||||||
# openapi:
|
openapi:
|
||||||
# endpoint: https://my.andert.me/api/v1
|
endpoint: https://my.andert.me/api/v1
|
||||||
# source: schemas/cloudron.json
|
source: schemas/cloudron.json
|
||||||
# operationHeaders:
|
operationHeaders:
|
||||||
# Authorization: Bearer {env.CLOUDRON_API}
|
Authorization: Bearer {env.CLOUDRON_API}
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"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",
|
"schema": "dotenv -- node ./src/fetch-schema.js",
|
||||||
"build": "mesh build && next build",
|
"build": "mesh build && next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
|
@ -7,12 +7,11 @@ type UserType = {
|
|||||||
|
|
||||||
const resolveUserFn = async context => {
|
const resolveUserFn = async context => {
|
||||||
const authHeader = context.req.headers.authorization;
|
const authHeader = context.req.headers.authorization;
|
||||||
if (authHeader !== "token123") {
|
const authtoken = process.env.GRAPHQL_MESH
|
||||||
|
if (authHeader !== authtoken) {
|
||||||
console.error('Failed to validate token')
|
console.error('Failed to validate token')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
// If the token is valid, return the user
|
|
||||||
// Replace this with your actual user fetching logic
|
|
||||||
return { id: 'user1' };
|
return { id: 'user1' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user