Skip to content

Commit a8ea331

Browse files
author
Pooya Parsa
committed
fix: don't mutate env.API_URL
This was causing side-effects and invalid proxy config after reloading nuxt.config.js
1 parent caa7b96 commit a8ea331

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/module.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ module.exports = function nuxtAxios (_moduleOptions) {
5252
/* istanbul ignore if */
5353
if (process.env.API_URL) {
5454
options.baseURL = process.env.API_URL
55-
} else {
56-
process.env.API_URL = options.baseURL
5755
}
5856

5957
/* istanbul ignore if */
@@ -93,6 +91,9 @@ module.exports = function nuxtAxios (_moduleOptions) {
9391
])
9492
}
9593

94+
// Set _AXIOS_BASE_URL_ for dynamic SSR baseURL
95+
process.env._AXIOS_BASE_URL_ = options.baseURL
96+
9697
/* eslint-disable no-console */
9798
debug(
9899
`BaseURL: ${chalk.green(options.baseURL)} (Browser: ${chalk.green(

lib/plugin.template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ export default (ctx, inject) => {
136136
const axiosOptions = {
137137
// baseURL
138138
baseURL : process.browser
139-
? (process.env.API_URL_BROWSER || '<%= options.browserBaseURL %>')
140-
: (process.env.API_URL || '<%= options.baseURL %>'),
139+
? '<%= options.browserBaseURL %>'
140+
: (process.env._AXIOS_BASE_URL_ || '<%= options.baseURL %>'),
141141

142142
// Create fresh objects for all default header scopes
143143
// Axios creates only one which is shared across SSR requests!

0 commit comments

Comments
 (0)