This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git


The following commit(s) were added to refs/heads/next by this push:
     new 8e32cf2  Adding api key for the request (#158)
8e32cf2 is described below

commit 8e32cf29672ff93e7767d7eace44ef59d8a8f5d6
Author: Nirojan Selvanathan <[email protected]>
AuthorDate: Wed Mar 18 10:34:30 2020 +0100

    Adding api key for the request (#158)
    
    * Adding api key for the request
    
    * Fixing review comments
---
 config/config.ts     | 2 ++
 src/utils/request.ts | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/config/config.ts b/config/config.ts
index 13a9a3b..369ca8c 100644
--- a/config/config.ts
+++ b/config/config.ts
@@ -205,3 +205,5 @@ export default {
   proxy: proxy[REACT_APP_ENV || 'dev'],
   chainWebpack: webpackPlugin,
 } as IConfig;
+
+export const API_KEY = 'edd1c9f034335f136f87ad84b625c8f1';
diff --git a/src/utils/request.ts b/src/utils/request.ts
index a58037a..f93ac77 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -4,6 +4,7 @@
  */
 import { extend } from 'umi-request';
 import { notification } from 'antd';
+import { API_KEY } from '../../config/config';
 
 const codeMessage = {
   200: '服务器成功返回请求的数据。',
@@ -50,6 +51,9 @@ const errorHandler = (error: { response: Response; data: any 
}): Promise<Respons
 const request = extend({
   errorHandler, // 默认错误处理
   credentials: 'include', // 默认请求是否带上cookie
+  headers: {
+    'X-API-KEY': API_KEY,
+  },
 });
 
 export default request;

Reply via email to