Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_SERVER_URL=http://localhost:3000
7 changes: 7 additions & 0 deletions constants/Env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Environment variables
*/
export const Env = {
NODE_ENV: process.env.NODE_ENV,
API_SERVER_URL: process.env.API_SERVER_URL,
}
1 change: 1 addition & 0 deletions constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./Env"
export * from "./IEnum"
export * from "./Page"
export * from "./SagaSetting"
Expand Down
15 changes: 14 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
const withCSS = require("@zeit/next-css")
const path = require("path")
const Dotenv = require("dotenv-webpack")

module.exports = withCSS()
module.exports = withCSS({
webpack: config => {
config.plugins = [
...config.plugins,
new Dotenv({
path: path.join(__dirname, ".env"),
systemvars: true,
}),
]
return config
},
})
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@types/react-redux": "^7.1.5",
"@types/redux": "^3.6.0",
"@types/styled-jsx": "^2.2.8",
"dotenv-webpack": "^1.7.0",
"prettier": "^1.19.1",
"redux-devtools-extension": "^2.13.8",
"tslint": "^5.20.1",
Expand Down
3 changes: 2 additions & 1 deletion store/api/InputApi.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Env } from "../../constants"
import { InputResponseModel } from "../../model"
import { IReduxSagaFetchPayload } from "../redux-saga"

export const fetchInputApi = (
payload: IReduxSagaFetchPayload
): Promise<InputResponseModel> => {
const url = `http://localhost:3000/api/input?value=${payload.input}`
const url = `${Env.API_SERVER_URL}/api/input?value=${payload.input}`
return fetch(url).then<InputResponseModel>(response => response.json())
}
3 changes: 2 additions & 1 deletion store/configureStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Env } from "../constants"
import { InitialState } from "../store/states"

const configureStoreComponent = (() => {
if (process.env.NODE_ENV === "production") {
if (Env.NODE_ENV === "production") {
return require("./configureStore.production")
}
return require("./configureStore.development")
Expand Down