Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Enable API_SERVER injection in netlify build #49

Merged
merged 4 commits into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
command = "yarn build"

[build.environment]
REACT_APP_API_SERVER = "https://sakuten-api-dev.herokuapp.com"
REACT_APP_API_SERVER = "https://sakuten-api-testflight.herokuapp.com"
REACT_APP_STAGING_BUILD = "1"

[[redirects]]
from = "/*"
Expand Down
2 changes: 1 addition & 1 deletion src/api/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios'
import deepAssign from 'deep-assign'
import docCookies from 'doc-cookies'

export const apiServer = (process.env.NODE_ENV === 'development' && docCookies.getItem('API_SERVER')) || process.env.REACT_APP_API_SERVER
export const apiServer = ((process.env.NODE_ENV === 'development' || process.env.REACT_APP_STAGING_BUILD) && docCookies.getItem('API_SERVER')) || process.env.REACT_APP_API_SERVER
export function fetchApi (endpoint, options) {
const opts = deepAssign(options, {
baseURL: apiServer,
Expand Down