瀏覽代碼

Using API_PATH config env var instead of API_URL

Since fingerprint hardened cookies, the api must be on the same domain.
We need a configurable api path only.
bodicsek 3 年之前
父節點
當前提交
438de01656
共有 4 個文件被更改,包括 12 次插入5 次删除
  1. 8 2
      ojet.config.js
  2. 1 1
      package.json
  3. 1 1
      src/globals.d.ts
  4. 2 1
      src/utils/environment.ts

+ 8 - 2
ojet.config.js

@@ -11,7 +11,7 @@ const package = require("./package.json");
 const developmentConfig = {
   plugins: [
     new webpack.DefinePlugin({
-      API_URL: JSON.stringify(process.env.API_URL)
+      API_PATH: JSON.stringify(process.env.API_PATH)
     })
   ],
   devServer: {
@@ -21,7 +21,13 @@ const developmentConfig = {
       "localhost",
       package.config.host
     ],
-    historyApiFallback: true
+    historyApiFallback: true,
+    proxy: {
+      "/api": {
+        target: process.env.API_URL || "http://localhost:3000",
+        pathRewrite: { "^/api": process.env.API_PATH || "" }
+      },
+    }
   }
 };
 

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "occ-fw-ui",
-  "version": "1.0.12",
+  "version": "1.0.13",
   "description": "An Oracle JavaScript Extension Toolkit(JET) web app",
   "config": {
     "host": "customercentral-poc.oracle.com",

+ 1 - 1
src/globals.d.ts

@@ -1 +1 @@
-declare const API_URL: string;
+declare const API_PATH: string;

+ 2 - 1
src/utils/environment.ts

@@ -1 +1,2 @@
-export const apiUrl = API_URL || `${window.location.origin}/api`;
+export const apiUrl = API_PATH || "/api";
+