From bdb507201496415d120bde5e0a4f83a253fc52a2 Mon Sep 17 00:00:00 2001 From: Isaac Grynsztein Date: Wed, 15 Apr 2020 18:46:13 -0400 Subject: [PATCH] API key is now passed as a query param --- backend/app.js | 4 ++-- src/app/posts.services.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/app.js b/backend/app.js index e14efe4..a8a7c82 100644 --- a/backend/app.js +++ b/backend/app.js @@ -1246,9 +1246,9 @@ app.use(function(req, res, next) { app.use(function(req, res, next) { if (!req.path.includes('/api/')) { next(); - } else if (req.headers.authorization === admin_token) { + } else if (req.query.apiKey === admin_token) { next(); - } else if (req.headers.authorization && config_api.getConfigItem('ytdl_use_api_key') && req.headers.authorization === config_api.getConfigItem('ytdl_api_key')) { + } else if (req.query.apiKey && config_api.getConfigItem('ytdl_use_api_key') && req.query.apiKey === config_api.getConfigItem('ytdl_api_key')) { next(); } else if (req.path.includes('/api/video/') || req.path.includes('/api/audio/')) { next(); diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts index 53ec330..8aa05d1 100644 --- a/src/app/posts.services.ts +++ b/src/app/posts.services.ts @@ -1,5 +1,5 @@ import {Injectable, isDevMode, Inject} from '@angular/core'; -import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { HttpClient, HttpParams } from '@angular/common/http'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; @@ -36,8 +36,8 @@ export class PostsService { } this.httpOptions = { - headers: new HttpHeaders({ - 'Authorization': '4241b401-7236-493e-92b5-b72696b9d853' + params: new HttpParams({ + fromString: `apiKey=${this.auth_token}` }), }; }