Skip to content

Instantly share code, notes, and snippets.

@syuji-higa
Last active November 16, 2019 04:05
Show Gist options
  • Save syuji-higa/b04a10b696829eacb734f45890aa7339 to your computer and use it in GitHub Desktop.
Save syuji-higa/b04a10b696829eacb734f45890aa7339 to your computer and use it in GitHub Desktop.
Nuxt.js - private IP API server
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