Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Nuxt 3 Compatibility #561

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function axiosModule (_moduleOptions) {
}

// Transpile defu (IE11)
if (nuxt.options.build.transpile /* nuxt 1 */) {
nuxt.options.build.transpile.push(({ isClient }) => isClient && 'defu')
if (nuxt.options.build.transpile && process.client/* nuxt 1 */) {
nuxt.options.build.transpile.push('defu')
}

// Default prefix
Expand Down
6 changes: 3 additions & 3 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const createAxiosInstance = axiosOptions => {
<% if (options.debug) { %>setupDebugInterceptor(axios) <% } %>
<% if (options.credentials) { %>setupCredentialsInterceptor(axios) <% } %>
<% if (options.progress) { %>setupProgress(axios) <% } %>
<% if (options.retry) { %>axiosRetry(axios, <%= serialize(options.retry) %>) <% } %>
<% if (options.retry) { %>axiosRetry(axios, JSON.parse('<%= JSON.stringify(options.retry) %>')) <% } %>

return axios
}
Expand Down Expand Up @@ -200,7 +200,7 @@ export default (ctx, inject) => {
// Create fresh objects for all default header scopes
// Axios creates only one which is shared across SSR requests!
// https://github.com/mzabriskie/axios/blob/master/lib/defaults.js
const headers = <%= JSON.stringify(options.headers, null, 4) %>
const headers = JSON.parse('<%= JSON.stringify(options.headers) %>')

const axiosOptions = {
baseURL,
Expand All @@ -211,7 +211,7 @@ export default (ctx, inject) => {
// Proxy SSR request headers headers
if (process.server && ctx.req && ctx.req.headers) {
const reqHeaders = { ...ctx.req.headers }
for (const h of <%= serialize(options.proxyHeadersIgnore) %>) {
for (const h of '<%= options.proxyHeadersIgnore %>'.split(',')) {
delete reqHeaders[h]
}
axiosOptions.headers.common = { ...reqHeaders, ...axiosOptions.headers.common }
Expand Down