LoginSignup
3
1

More than 3 years have passed since last update.

nuxtでaxiosのbaseURL 設定(dotenv使用時)

Posted at

nuxt.config.js

ソースに

  if (process.env.API_URL) {
    options.baseURL = process.env.API_URL
  }

と書いてあるので

/nuxt.config.js の頭に下記定義を追加して


require('dotenv').config()

.envに

API_URL=http://192.168.99.100:8000/api

とか書いとけばいいっぽい

nuxt.config.js内の axios {} 内はとくにいじらなくていいっぽい

参考
https://omiend.hatenablog.jp/entry/2019/04/18/191449

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1