Activities

dekadentno

dekadentno posted a new feature request

http •

idea Make port optional

What problem does this feature solve?

The port should be optional because there are many public (and non public) APIs that don't require the port in the Request URL.

What does the proposed changes look like?

In nuxt.config.js it should be possible to do

  http: {
    host: 'bla.bla.com',
    port: null, // or `false`
    prefix: '/v1' 
  }
lightmyfire17

lightmyfire17 posted a new bug report

http •

bug Unable to get server error message on catch

Version

v0.5.0

Reproduction link

https://jsfiddle.net/eobk1pam/1/

Steps to reproduce

Use any HTTP Methods via $http ($get, delete, $put, etc.), try to catch the error like:
this.$http .$get("http://nuxthttperrors.io/error") .then(resp => console.log(resp)) .catch(e => console.log(e.response.data));

What is expected ?

Expected to get the error response message, like in network tab in chrome.

P.S. Working like a charm in axios.

What is actually happening?

The error response object is always empty:
{ name: "HTTPError", response: {} }

csheppard

csheppard posted a new bug report

http •

bug Docs example for setToken with request type

Version

v0.5.0

Reproduction link

https://http.nuxtjs.org/guide/advanced.html#settoken-token-type

Steps to reproduce

The example in the docs shows you can set it by request type but the functionality doesn't exist. Planned for future perhaps?

// Adds header: `Authorization: Bearer 123` to only post and delete requests
this.$http.setToken('123', 'Bearer', ['post', 'delete'])

What is expected ?

Set token by request type

What is actually happening?

Not possible

p-moreira

p-moreira posted a new question

http •

Module not found Error

Hi, I'm trying to build my Nuxt app (nuxt build) and I get this error about the "ky-universal".

WARNING in ./node_modules/ky-universal/index.js
Module not found: Error: Can't resolve 'web-streams-polyfill/ponyfill/es2018'

Need I to open a bug Issue?

Thanks

darthf1

darthf1 posted a new question

http •

Globally set options.Credentials

Hi. Is there a way to globally set options.credentials = 'include'? I tried with the onRequest hook but then I get a TS error.

import { Plugin } from '@nuxt/types'

const httpPlugin: Plugin = ({ $http }) => {
  $http.onRequest((config) => {
    config.credentials = 'include'
  })
}

export default httpPlugin
`TS2540: Cannot assign to 'credentials' because it is a read-only property.`

If I add a // @ts-ignore on this error, the request won't be made. If I remove the code all together, the request is made.

Is there another way to set this globally instead of every request?

felixdenoix

felixdenoix posted a new bug report

http •

bug Authorization headers set on the server are not persisted on the client

Version

v0.3.8

Reproduction link

https://codesandbox.io/s/priceless-voice-3mnwh

Steps to reproduce

Set Authorization headers during nuxtServerInit action in the store, they won't be present anymore in the client $http instance ($http._defaults.headers) afterwards

What is expected ?

the Authorization headers set on the $http instance server-side should be present in the $http instance client-side

What is actually happening?

the headers are empty client-side

Additional comments?

Not sure if this behaviour is intended ( and thus if its an issue) but it feels a bit odd having to set the request headers on both sides attended that I'm setting the header using the client cookies whenever available and that the client context is supposed to be hydated by the server-side data, right ?

felixdenoix

felixdenoix posted a new question

http •

Authorization headers set on the server are not persisted on the client

Hello,

Whenever I set the Authorization header server-side using the nuxtServerInit action in the store, it is not present anymore on the client when the app is mounted.
Is it the intended behavior ? It feels a bit odd having to set the request headers on both sides attended that I'm setting this token using the client cookies whenever available and that the client context is supposed to be hydated by the server-side data, right ?

I've made a reproduction here: https://codesandbox.io/s/priceless-voice-3mnwh in whitch I'm setting a header in the nuxtServerInit action and saving the $http._defaults.headers to display them along side with the client headers.

Regards

Félix

lcherone

lcherone posted a new question

http •

$http.get(...).text is not a function

I'm getting the above error using code directly taken from the example in docs:

https://http.nuxtjs.org/guide/usage.html#using-in-asyncdata

 "dependencies": {
    "@nuxt/http": "^0.3.8",
<template>
  <pre>{{ ip }}</pre>
</template>

<script>
export default {
  async asyncData({ $http }) {
    const ip = await $http.get('http://icanhazip.com').text()
    return { ip }
  }
};
</script>

browser

screenshot-localhost_3000-2019 12 22-00_15_20

console

 ERROR  $http.get(...).text is not a function                                                      00:10:30

  at asyncData (about.vue:16:0)
  at promisify (.nuxt/utils.js:245:0)
  at Promise.all.Components.map.Component (.nuxt/server.js:215:0)
  at Array.map (<anonymous>)
  at module.exports../.nuxt/server.js.__webpack_exports__.default (.nuxt/server.js:210:0)
VadimCeretean

VadimCeretean posted a new question

http •

request to failed, reason: unable to verify the first certificate

request to failed, reason: unable to verify the first certificate
How to fix it?

VadimCeretean

VadimCeretean posted a new question

http •

request to failed, reason: unable to verify the first certificate

how to fix: unable to verify the first certificate?

kondrDev

kondrDev posted a new question

http •

Doesn't work in EDGE IE

How i can to start application on NUxt with Http module on IE EDGE? Maybe has some polyfill?

ThePeach

ThePeach posted a new feature request

http •

idea Allow change of baseURL in onRequest hook

What problem does this feature solve?

this is very much a runtime/environment variable issue. In order to use variables defined by nuxt-env, I would have to have access to the app object. This is something currently doable with the axios module

What does the proposed changes look like?

the config object should have have a baseURL variable, and the final url shouldn't be computed already.

pi0

pi0 posted a new question

http •

allow adding custom headers with nuxt config

nuxt-community/axios-module#294

usb248

usb248 posted a new question

http •

usb248

usb248 posted a new feature request

http •

idea Integrate retry functionnality like axios-retry

What problem does this feature solve?

What does the proposed changes look like?

Something like this :

httpRetry($http, {
        retries: 2,
        retryDelay: httpRetry.exponentialDelay,
        retryCondition : function(err){
            return err.status >= 400 && err.data.hasOwnProperty('retry') && err.data.retry
        }
    })
usb248

usb248 posted a new question

http •

Integrate retry functionnality like axios-retry

Possible ?

acrolink

acrolink posted a new bug report

http •

bug $http is undefined in async asyncData method in production (nuxt build && nuxt start)

Version

v0.3.5

Reproduction link

https://jsfiddle.net/yqr9s70a/

Steps to reproduce

The following code works perfect in development (nuxt script):

  async asyncData({ $http }) {
    let response = await $axios.get(`/api/items`)
    return { entities: response.data.data }
  }

However, in production (nuxt build && nuxt start) I get this error:

ERROR Cannot read property '$get' of undefined 07:59:22

  at asyncData (df028d49c11282eafe57.js:1:0)
  at C (server.js:1:0)
  at Promise.all.h.map.n (server.js:1:0)
  at Array.map (<anonymous>)
  at e.default (server.js:1:0)

What is expected ?

To work in production as it does on development

What is actually happening?

Error

beeplove

beeplove posted a new question

http •

Header name 'authorization' vs 'Authorization'

Just curious why this team has chosen 'authorization' instead of very typical 'Authorization'

https://github.com/nuxt/http/blob/dev/lib/plugin.js#L23

emuter

emuter posted a new question

http •

not able to set custom header Content-Type on post requests

not able to set custom header Content-Type on post requests

happycoder97

happycoder97 posted a new bug report

http •

bug Build fails with typescript

Version

v0.3.2

Reproduction link

https://github.com/happycoder97/nuxt-http-typescript-bug1-repro

Steps to reproduce

Just run yarn dev

What is expected ?

App compiles successfully.

What is actually happening?

Typechecking fails.