API_URL env

This commit is contained in:
chenos 2021-07-23 18:26:05 +08:00
parent 3223d95d01
commit 3c3fa358de
7 changed files with 60 additions and 4 deletions

View File

@ -3,6 +3,9 @@ import { defineConfig } from 'dumi';
export default defineConfig({
title: ' ',
hash: true,
define: {
'process.env.API_URL': process.env.API_URL,
},
// ssr: {},
// exportStatic: {},
mode: 'site',

View File

@ -7,6 +7,7 @@
"scripts": {
"bootstrap": "lerna bootstrap",
"clean": "lerna clean",
"start": "cd packages/app && npm start",
"start-server": "nodemon",
"start-docs": "dumi dev",
"build-docs": "dumi build",

View File

@ -1,9 +1,18 @@
import { defineConfig } from 'umi';
import dotenv from 'dotenv';
import path from 'path';
dotenv.config({
path: path.resolve(__dirname, '../../.env'),
});
export default defineConfig({
nodeModulesTransform: {
type: 'none',
},
define: {
'process.env.API_URL': process.env.API_URL,
},
routes: [
{ path: '/', exact: false, component: '@/pages/index' },
],

View File

@ -2,7 +2,7 @@
"name": "@nocobase/app",
"version": "0.4.0-alpha.7",
"scripts": {
"start": "umi dev",
"start": "concurrently \"cd ../../ && nodemon\" \"umi dev\"",
"build": "umi build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
@ -29,6 +29,7 @@
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@umijs/test": "^3.4.15",
"concurrently": "^5.3.0",
"mockjs": "^1.1.0",
"prettier": "^2.2.0",
"react": "17.x",

View File

@ -15,10 +15,12 @@ import { UseRequestProvider } from 'ahooks';
import { extend } from 'umi-request';
const request = extend({
prefix: 'http://localhost:23003/api/',
prefix: process.env.API_URL,
timeout: 1000,
});
console.log('process.env.API_URL', process.env.API_URL);
// console.log = () => {}
const RouteSwitch = createRouteSwitch({

View File

@ -62,9 +62,10 @@ export function useDefaultAction() {
}
export const request = extend({
prefix: 'http://localhost:23003/api/',
prefix: process.env.API_URL,
timeout: 1000,
});
console.log('process.env.API_URL', process.env.API_URL);
export async function createOrUpdateCollection(data: any) {
return await request('collections:createOrUpdate', {

View File

@ -6189,6 +6189,21 @@ concat-with-sourcemaps@^1.0.5, concat-with-sourcemaps@^1.1.0:
dependencies:
source-map "^0.6.1"
concurrently@^5.3.0:
version "5.3.0"
resolved "https://registry.nlark.com/concurrently/download/concurrently-5.3.0.tgz?cache=0&sync_timestamp=1621853991537&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fconcurrently%2Fdownload%2Fconcurrently-5.3.0.tgz#7500de6410d043c912b2da27de3202cb489b1e7b"
integrity sha1-dQDeZBDQQ8kSston3jICy0ibHns=
dependencies:
chalk "^2.4.2"
date-fns "^2.0.1"
lodash "^4.17.15"
read-pkg "^4.0.1"
rxjs "^6.5.2"
spawn-command "^0.0.2-1"
supports-color "^6.1.0"
tree-kill "^1.2.2"
yargs "^13.3.0"
config-chain@^1.1.11:
version "1.1.13"
resolved "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz#fad0795aa6a6cdaff9ed1b68e9dff94372c232f4"
@ -6881,6 +6896,11 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"
date-fns@^2.0.1:
version "2.23.0"
resolved "https://registry.nlark.com/date-fns/download/date-fns-2.23.0.tgz?cache=0&sync_timestamp=1627020353586&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdate-fns%2Fdownload%2Fdate-fns-2.23.0.tgz#4e886c941659af0cf7b30fafdd1eaa37e88788a9"
integrity sha1-TohslBZZrwz3sw+v3R6qN+iHiKk=
date-fns@^2.15.0:
version "2.22.1"
resolved "https://registry.npmjs.org/date-fns/-/date-fns-2.22.1.tgz#1e5af959831ebb1d82992bf67b765052d8f0efc4"
@ -15880,6 +15900,15 @@ read-pkg@^3.0.0:
normalize-package-data "^2.3.2"
path-type "^3.0.0"
read-pkg@^4.0.1:
version "4.0.1"
resolved "https://registry.npm.taobao.org/read-pkg/download/read-pkg-4.0.1.tgz?cache=0&sync_timestamp=1616914967500&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fread-pkg%2Fdownload%2Fread-pkg-4.0.1.tgz#963625378f3e1c4d48c85872b5a6ec7d5d093237"
integrity sha1-ljYlN48+HE1IyFhytabsfV0JMjc=
dependencies:
normalize-package-data "^2.3.2"
parse-json "^4.0.0"
pify "^3.0.0"
read-pkg@^5.2.0:
version "5.2.0"
resolved "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz#7bf295438ca5a33e56cd30e053b34ee7250c93cc"
@ -16766,7 +16795,7 @@ run-queue@^1.0.0, run-queue@^1.0.3:
dependencies:
aproba "^1.1.1"
rxjs@^6.4.0:
rxjs@^6.4.0, rxjs@^6.5.2:
version "6.6.7"
resolved "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz#90ac018acabf491bf65044235d5863c4dab804c9"
integrity sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==
@ -17259,6 +17288,11 @@ space-separated-tokens@^1.0.0:
resolved "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz#85f32c3d10d9682007e917414ddc5c26d1aa6899"
integrity sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==
spawn-command@^0.0.2-1:
version "0.0.2-1"
resolved "https://registry.npm.taobao.org/spawn-command/download/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"
integrity sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A=
spdx-correct@^3.0.0:
version "3.1.1"
resolved "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9"
@ -18198,6 +18232,11 @@ tr46@^2.1.0:
dependencies:
punycode "^2.1.1"
tree-kill@^1.2.2:
version "1.2.2"
resolved "https://registry.npm.taobao.org/tree-kill/download/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
integrity sha1-TKCakJLIi3OnzcXooBtQeweQoMw=
trim-newlines@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"