Created
January 5, 2019 18:24
-
-
Save roikiermedia/c9c9b700187147d58be37aa471f3d4f7 to your computer and use it in GitHub Desktop.
set host & port for axios instance
This file contains 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
// set host & port for axios instance | |
// https://github.com/nuxt-community/express-template/blob/master/template/plugins/axios.js | |
import * as axios from "axios"; | |
let options = {}; | |
// The server-side needs a full url to work | |
if (!process.browser) { | |
options.baseURL = `http://${process.env.HOST || "localhost"}:${process.env.PORT || 3000}`; | |
} | |
export default axios.create(options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment