hyeonsu lee
hyeonsu lee

Reputation: 75

nuxt.js axios request is sometimes slow only at chrome

I've recently been working on a nuxtjs, and I've been experiencing a strange phenomenon.

At nuxtjs, http request is made using axios module with proxy module. Requesting directly to the localhost:8080 where api operates is very fast. (about 4~6ms)

However, when proxy is enabled, the request(port 3000) is sometimes delayed to about 300mm. The strange thing is that it only slows down in chrome. (about 300~350ms)

chrome devtool request capture(1)

chrome devtool request capture(2)

nuxt.config.js

module.exports = {
    modules: [
        '@nuxtjs/axios',
        '@nuxtjs/bulma',
        '@nuxtjs/font-awesome'
    ],
    plugins: [
        '~/plugins/axios'
    ],
    axios: {
        proxy: true,
        credentials: true
        // proxyHeaders: false,
        // https: true
    },
    proxy: {
        '/api/': { target:'http://localhost:8080', pathRewrite: {'^/api/': ''}  }
    },
    ...
}

Given that the request for favicon.ico as well as the axios request sometimes takes 300ms, it is assumed that the request from the nuxtjs is delayed for some reason in the chrome, not just the problem with the axios proxy module.

If you have experienced the same thing, I would appreciate it if you would respond.

thank you

Upvotes: 2

Views: 1370

Answers (1)

hyeonsu lee
hyeonsu lee

Reputation: 75

I knew it only happens when I use localhost. So I changed it to 127.0.0.1 or another custom domain. I haven't found a clear cause, but I'm glad it's settled for now. Thank you.

Upvotes: 5

Related Questions