Skip to content

Instantly share code, notes, and snippets.

@roikiermedia
Created January 5, 2019 18:24
Show Gist options
  • Save roikiermedia/c9c9b700187147d58be37aa471f3d4f7 to your computer and use it in GitHub Desktop.
Save roikiermedia/c9c9b700187147d58be37aa471f3d4f7 to your computer and use it in GitHub Desktop.
set host & port for axios instance
// 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