This repository was archived by the owner on Jul 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +43
-29
lines changed Expand file tree Collapse file tree 8 files changed +43
-29
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ module.exports = {
1010 srcDir : 'src/' ,
1111
1212 env : {
13- NODE_ENV : process . env . NODE_ENV
13+ NODE_ENV : process . env . NODE_ENV ,
14+ BUILD_ENV : process . env . BUILD_ENV ,
15+ envName : process . env . envName ,
16+ internalEndpointUrl : process . env . internalEndpointUrl ,
17+ externalEndpointUrl : process . env . externalEndpointUrl
1418 } ,
1519
1620 // https://qiita.com/toaru/items/0690a9110c94052bb479
Original file line number Diff line number Diff line change 11import Env from '@/common/env/'
22
3- const getBffUrl = ( path : string ) : string => [ Env . url , path ] . join ( '' )
3+ /**
4+ * BFF(バックエンドフォーフロントエンド)用の URL を作成する
5+ * @param path
6+ */
7+ const getBffUrl = ( path : string ) : string => {
8+ let url : string
9+ if ( process . server ) {
10+ url = [ Env . internalEndpointUrl , path ] . join ( '' )
11+ } else {
12+ url = [ Env . externalEndpointUrl , path ] . join ( '' )
13+ }
14+ return url
15+ }
416
517/** API のエンドポイント */
618export const API_ENDPOINT = {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ const Env = {
2+ envName : 'local' ,
3+ internalEndpointUrl : 'http://localhost:5000' ,
4+ externalEndpointUrl : 'http://localhost:5000'
5+ }
6+
7+ export default Env
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import EnvDev from './env.dev'
2- import EnvStg from './env.stg'
3- import EnvProd from './env.prod'
1+ import EnvLocal from './env.local'
42import { IEnv } from '@/interface/IEnv'
53
64console . log ( 'process.env.NODE_ENV: ' , process . env . NODE_ENV )
5+ console . log ( 'process.env.BUILD_ENV: ' , process . env . BUILD_ENV )
76
87let Env : IEnv
9- if ( process . env . NODE_ENV === 'production' ) {
10- Env = EnvProd
11- } else if ( process . env . NODE_ENV === 'staging' ) {
12- Env = EnvStg
8+ if ( process . env . BUILD_ENV === 'docker' ) {
9+ /** docker のビルド環境の環境変数から値を取ってくる */
10+ Env = {
11+ envName : process . env . envName ,
12+ internalEndpointUrl : process . env . internalEndpointUrl ,
13+ externalEndpointUrl : process . env . externalEndpointUrl
14+ } as IEnv
1315} else {
14- Env = EnvDev
16+ /** docker でビルドされていない場合は、 .env.local から値を取ってくる */
17+ Env = EnvLocal
1518}
1619
20+ console . log ( 'Env:' , Env )
21+
1722export default Env
Original file line number Diff line number Diff line change 22 * Env インターフェイス
33 */
44export interface IEnv {
5+ /** 環境名 */
56 envName : string
6- url : string
7+ /** 内部向けエンドポイント URL */
8+ internalEndpointUrl : string
9+ /** 外部向けエンドポイント URL */
10+ externalEndpointUrl : string
711}
You can’t perform that action at this time.
0 commit comments