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
|
||||
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}
|
||||
|
@ -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",
|
||||
|
@ -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' };
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user