Last active
November 16, 2019 04:05
-
-
Save syuji-higa/b04a10b696829eacb734f45890aa7339 to your computer and use it in GitHub Desktop.
Nuxt.js - private IP API server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import internalIp from 'internal-ip' | |
export default async () => { | |
let apiBaseUrl = 'http://localhost:8000/api/v1' | |
if (process.env.NODE_ENV === 'develop') { | |
const ip = await internalIp.v4() | |
apiBaseUrl.replace(/localhost|127\.0\.0\.1|0\.0\.0\.0/, ip) | |
} | |
const nuxtConfig = { | |
axios: { | |
baseURL: apiBaseUrl | |
} | |
} | |
return nuxtConfig | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment