Activities

zzzmisa

zzzmisa posted a new bug report

axios-module •

bug Security vulnerability in transitive dependency

Version

v5.6.0

Reproduction link

*

Steps to reproduce

Run: $ srcclr scan

Vulnerabilities - Premium Data
RESERVED (CVE-2019-10746)                 Medium Risk     Prototype Pollution     mixin-deep 1.3.2

What is expected ?

No security vulnerability

What is actually happening?

According to SourceClear, Axios Module v5.6.0 imports transitive dependencies that are impacted by the following vulnerability.

I see these import routes:

@nuxtjs/axios@5.6.0 > @nuxtjs/proxy@1.3.3 > http-proxy-middleware@0.19.1 > micromatch@3.1.10 > snapdragon@0.8.2 > base@0.11.2 > mixin-deep@1.3.2

For your information:

  • Micromatch v4.0.0 has dropped Snapdragon.
  • The latest version of Http-proxy-middleware v0.20.0-beta.0 is using [email protected]^4.0.2.

Is it possible to use the latest version of Http-proxy-middleware?

rikless

rikless posted a new feature request

axios-module •

idea Brotli support removed

What problem does this feature solve?

In the past, Brotli was not supported on nodejs servers.

If I understand correctly, this is now supported since a few months : https://github.com/nodejs/node/pull/20458

This PR dropped support for Brotli : https://github.com/nuxt-community/axios-module/pull/180

Maybe it's time to revert this BR because Axios is supporting it too : https://github.com/axios/axios/pull/2071

What does the proposed changes look like?

Revert this PR https://github.com/nuxt-community/axios-module/pull/180

stirredo

stirredo posted a new question

axios-module •

How to mock this.$axios in jest?

I am trying to test vuex store in isolation (Meaning: without trying to load the whole vue or nuxt, testing the getters, mutations, and actions).

Is there a way we can mock this.$axios?

Is this supported in @nuxt/axios?

Is there a complete example which I can refer to get going?

daniluk4000

daniluk4000 posted a new bug report

axios-module •

bug Progress property for requests isn't working

Version

v5.5.4

Reproduction link

https://github.com/daniluk4000/nuxt-axios-bug

Steps to reproduce

  1. Create any request to any site
  2. Add to options parameter progress: false, like it's described in docs (https://axios.nuxtjs.org/options#progress)

What is expected ?

Progress bar is not showing up for this request

What is actually happening?

Progress bar is still here, and not disappeared

Additional comments?

AxiosRequestConfig does not contain parameter progress. This can be the case it's not working.

matthieusieben

matthieusieben posted a new feature request

axios-module •

idea Do not use localhost:3000 as default in production

What problem does this feature solve?

If eveything else fails, baseURL will default to http://localhost:3000.

While this is nice in dev environement, it might cause production environement to use http://localhost:3000 as default, if not configured properly.

This lead to error in my deployment because I didn't configure the module correctly but din't realise my mistake until it was too late.

I believe that a better behaviour would be to throw ASAP in that case, preventing the deployment of faulty code.

What does the proposed changes look like?

let defaultPort =
  // ...
  (process.env.NODE_ENV === 'development' && 3000)

let defaultHost =
  // ...
  (process.env.NODE_ENV === 'development' && 'localhost')

if (!defaultPort || !defaultHost) throw new Error('Configuration error')
matthieusieben

matthieusieben posted a new question

axios-module •

baseURL should not use development defaults

If eveything else fails, baseURL will default to http://localhost:3000.

While this is nice in dev environement, it might cause production environement to use http://localhost:3000 as default, if not configured properly.

This lead to error in my deployment because I didn't configure the module correctly but din't realise my mistake until it was too late.

I believe that a better behaviour would be to throw ASAP in that case, preventing the deployment of faulty code.

padinko

padinko posted a new feature request

axios-module •

idea Export CancelToken

What problem does this feature solve?

Can @nuxtjs/axios export CancelToken too?
So I gan use only import { CancelToken } from '@nuxtjs/axios'; which I already have in dependencies
instad of import { CancelToken } from 'axios'; which need to be additionally added to dependencies

pimlie

pimlie posted a new feature request

axios-module •

idea Report time-based progress

What problem does this feature solve?

Related PR in which this was tracked down: https://github.com/nuxt-community/axios-module/pull/229

Progress events in XMLHttpRequest / axios are based on the bytes transferred, not of the estimated time the request has taken.

What does the proposed changes look like?

It would be nice if we could configure progress events based on time (out of a preset expected total time) instead of data transferred.

WhileLoop

WhileLoop posted a new feature request

axios-module •

idea Support continuous progress bar.

What problem does this feature solve?

I have the following in nuxt.config.js

  loading: {
    duration: 2000,
    continuous: true
  },

I confirmed that during slow page loads the progress bar is continuous but during slow axios requests it get stuck at 100% after duration has elapsed. Is there any way to make this module support continuous mode?

BiswasSuman

BiswasSuman posted a new question

axios-module •

mutations or commit not working when page reload
export const state = () => ({
  user : {}
})

export const mutations = {
  set_user: (state, data) => state.user = data
}

export const actions = {
  initAuth(vuexContext, token){
    if( token ){

      /**
       * This commit working
       */
      vuexContext.commit('set_user', {name: 'sunny'})

      /**
       * But if I want to commit after this get request, it not working,
       * But consoling correct response
       */
      this.$axios.$get('/me')
      .then(res => {
        vuexContext.commit('set_user', res)
        console.log(res)
      })
      .catch(err => console.log(err.response))
    }

  }
}
sowinski

sowinski posted a new question

axios-module •

Dynamic baseUrl: Get baseURL from request

Hi,

I have a multilingual website with 27 different Domains.

For example:
www.exmple.com
www.example.it
www.somethingdifferent.at

if someone is opening the website from www.example.com then my baseURL should be set to www.example.com
If someone is opening the website from www.somethingdifferent.at then my baseURl should be set to www.somethingdifferent.at

How can I do this?
(I need this because I use cookie based authentication.)

Thank you :)

gitzhaochen

gitzhaochen posted a new question

axios-module •

setHeader application/x-www-form-urlencoded and use POST method , still send OPTIONS preflight first time ??
//plugin/axios.js

export default ({ $axios, redirect, error, app, route, env }, inject) => {
  $axios.setHeader('Content-Type', 'application/x-www-form-urlencoded')

  inject('post', async (name, body = {}) => {
    const data = await $axios.$post('web.api', datastr)
    return data
  })
}
// vue components
async mounted() {
    let goodsDataRes = await this.$post('items.getItem', { itemId: this.$route.params.id })
    this.goodsData = goodsDataRes.data
}
// vue components
async mounted() {
    let goodsDataRes = await this.$post('items.getItem', { itemId: this.$route.params.id })
    this.goodsData = goodsDataRes.data
}
// nuxt.config.js
axios: {
    credentials: true,//send cookie
    baseURL: `http://api.xxx.com`,
    proxy: false
}
zacharytyhacz

zacharytyhacz posted a new question

axios-module •

Cookies/ Credentials Not Saving; How to Send Default Headers?

I am interacting with a backend API that sets an authentication cookie for further authenticated requests after logging in. I've looked into credentials: true, but it is still not cooperating properly.

Do I need to set a specific header value or is something wrong with my axios configuration?

I also cannot find any resources on how to set up default headers or properly setup proxies with any examples. The README for this module is absolutely subpar or outdated; I can't find good example for practical use.

I just want to keep and use this cookie received from logging in successfully and use it in the next requests to make authenticated requests.

// nuxt.config.js
axios : {
    ...
    credentials: true,
    ...
},

and here is where I am making my axios request

async asyncData({ $axios}) {
    try {
        // this response sends back an authentication cookie
        const login_response = await $axios.$post("my_login_route",{
            password : this.password,
            username : this.email,
        });

        if(login_response.success){
            // how i send my cookie to this route to prove im authenticated?
            const authenticated = await $axios.$get("my_url");
            console.log(authenticated); // always false; doesn't send cookie recieved in login $post request
        }else{
            console.log("Invalid username or password");
        }
    } catch(error) {
        console.log(error);
    }
}

I've made a test page with making a simple request to check if the user is authenticated. Turns out, the axios settings in the nuxt.config.js are NOT being applied here.

I need the axios configuration to apply to not just the base URL, but to my API routes. Here is a test method that activates when I press a test button:

check_auth : async function(){
    try {
        const response = await this.$axios.$get("https://<my_url>/Utility/IsAuthenticated/");
        console.log("IS AUTH:");
        console.log(response.isAuthenticated);
    }catch(error){
        console.log("something went wrong.");
    }
},

HTTP REQUEST HEADERS FOR AXIOS REQUEST MADE RIGHT ABOVE
As you can see, there are no cookies or API-Key headers that I specified in the axios config.

Host: <my_url>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:67.0) Gecko/20100101 Firefox/67.0
Accept: application/json, text/plain
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: http://localhost:1337/send/account
Origin: http://localhost:1337
DNT: 1
Connection: keep-alive

What do I need to change in my axios nuxt.config.js section to allow the axios configuration to apply to my api route? Do i need to use the proxy:{} section?

I've been attempting to set up a proxy, though any proxy settings I create will just add /api/ to my baseURL and 404ing,

renovate[bot]

renovate[bot] posted a new question

axios-module •

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (@nuxtjs)

CHEWX

CHEWX posted a new question

axios-module •

SSR and CSR confusion

Hi,

Little confused with proxying requests.

Currently I cannot get both SSR and CSR working at the same time, but can get them working individually.

Request:
return $axios.get( '/pages/123' )

Config:
nuxt.config.js

axios: {
    proxy: true,
    proxyHeaders: false,
    baseURL: process.env.NODE_ENV === 'development' ? 'http://local-api.test/wp-json/wp/v2' : 'https://user:[email protected]/wp-json/wp/v2',
},
proxy: {
    '/data/': {
        target: process.env.NODE_ENV === 'development' ? 'http://local-api.test/wp-json/wp/v2' : 'https://user:[email protected]/wp-json/wp/v2',
        pathRewrite: {
            '^/data/': '/'
        }
    }
},

SSR will correctly fetch 123 route and render. However, if I go to another page and go back to this page and fetch via CSR, then it will request incorrectly to a page, not a endpoint.

However, if I change the request from return $axios.get( '/pages/123' ) to return $axios.get( '/data/pages/123' ), CSR will work correctly, but SSR will 404 Request failed with status code 404.

How can I get both CSR and SSR working?

Thanks,
Tom

dingguoqing513

dingguoqing513 posted a new question

axios-module •

this.$axios.CancelToken is not a function

my dependencies is @nuxt/axios 5.5.4

karambafe

karambafe posted a new bug report

axios-module •

bug progress: false does not work in version 5.5.3

Version

v5.5.3

Reproduction link

https://codesandbox.io/s/8n6z6z30j8

Steps to reproduce

Add progress: false in request config:

this.$axios.get('URL', { progress: false });
this.$axios.post('URL', { data: 'data' }, { progress: false });

What is expected ?

progress bar is not displayed

What is actually happening?

Progress bar displayed for all types of requests (get, post, patch, delete)

Additional comments?

in version 5.3.6 it works correctly

cdwmhcc

cdwmhcc posted a new bug report

axios-module •

bug Refreshing pages and returning data formats via routing jumps are different

Version

v5.5.3

Reproduction link

https://zh.nuxtjs.org/

Steps to reproduce

async asyncData({ app, params, error, payload }) {
const list = await app.context.app.$axios.$get('/api/items/soft',{
params:{
status: "published"
}
})
return {
post: data.data[0]
}
},

刷新页面返回数据一切正常:

{
data: [{
id: 1,
title:'Hello World'
}]
meta: {
result_count: 1
}
}

1.jpg

通过路由跳转返回的数据:

{
id: 1,
title:'Hello World'
}

2.jpg

meta不见了

What is expected ?

数据返回一致

What is actually happening?

我有一篇文章,它的url是xxxx.com/blog/helloworld
我直接通过url访问,数据是正常的,
但是当我通过<NuxtLink :to="'/blog/helloworld‘">Hello World</NuxtLink>访问的时候,返回的数据就不正常了,具体的可以我上传的图片

kirillbunin

kirillbunin posted a new bug report

axios-module •

bug Setting defaults with SSR

Version

v5.5.3

Reproduction link

*

Steps to reproduce

I have following in my nuxt.config.js:

  modules: [
    '@nuxtjs/axios',
  ],
  axios: {
    debug: process.env.NODE_ENV !== 'production',
    baseURL: process.env.NODE_ENV === 'production' ? 'https://production/api/' : 'https://staging/api/',
    browserBaseURL: process.env.NODE_ENV === 'production' ? 'https://production/api/' : 'https://staging/api/',
    credentials: true,
    proxyHeaders: true,
    init (axios, ctx) {
      axios.defaults.xsrfHeaderName = 'X-CSRF-TOKEN'
    }
  },

What is expected ?

To change the default xsrfHeaderName to X-CSRF-TOKEN

What is actually happening?

When I make requests on my API's, I get error Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://staging/api/transaction?_format=json. (Reason: missing token ‘x-xsrf-token’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel).
(Notice the xsrf, not csrf)

Additional comments?

If I create a nuxt-client-init.jswith:

export default ({ app }) => {
 app.$axios.defaults.xsrfHeaderName = 'X-CSRF-TOKEN'
}

and in my nuxt.config.js I put

  plugins: [
    { src: '~/plugins/nuxt-client-init.js', ssr: false },
  ],

It works as expected.

kamikazechaser

kamikazechaser posted a new question

axios-module •

Auth cookie not being sent with request

Requests made with axios do not accompany the relevant auth cookie. Below are my configurations:

Server is running on port 5000, SPA on 3000

  axios: {
    credentials: true,
    baseURL: "http://127.0.0.1:5000/",
    debug: true
  },
  auth: {
    strategies: {
      local: {
        endpoints: {
          login: { url: '/auth/login', method: 'post', propertyName: 'token' },
          logout: false,
          user: { url: '/auth/user', method: 'get', propertyName: 'user' }
        },
        tokenRequired: true,
        tokenType: 'bearer'
      }
    }
  }

Here is the sample request:

  methods: {
    async test() {
        const req = await this.$axios.$post('http://127.0.0.1:5000/auth/verify');
    }
  }

Here is the CORS config on the server:

Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin: http://localhost:3000

The JWT cookie is stored in the cookie store, however its not being sent with the request. What could be the issue?, since I feel the configuration is okay.