Activities

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.

happycoder97

happycoder97 posted a new question

http •

Unable to compile nuxt app due to error in `@nuxt/http`
 ERROR  ERROR in /<..snip..>/project/node_modules/@nuxt/http/types/index.d.ts                                                        15:28:35
2:85 Module '"../../../ky"' has no exported member 'JSONValue'.
    1 | import Vue from 'vue'
  > 2 | import { ResponsePromise, Options, BeforeRequestHook, AfterResponseHook, HTTPError, JSONValue } from 'ky'
      |                                                                                     ^
    3 | import './vuex'
    4 | 
    5 | type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

ℹ Version: typescript 3.5.2              
                                                                                          

From yarn.lock:

@nuxt/[email protected]^0.3.2
[email protected]^0.11.0
pimlie

pimlie posted a new feature request

http •

idea change browserBaseUrl default value to '/'

What problem does this feature solve?

Currently the default value of browserBaseUrl is baseUrl which works correctly if you are running your server on localhost as well. But when running Nuxt with HOST=0.0.0.0 then baseUrl and thus browseBaseUrl still fallbacks to localhost. This is fine for baseUrl, but browserBaseUrl shouldnt probably be pointing to localhost.

Related issue: https://github.com/nuxt/press/issues/2 (as fix in nuxtpress I just added browserBaseUrl: '/' as option)

What does the proposed changes look like?

Set default value for browserBaseUrl to /

jefrydco

jefrydco posted a new feature request

http •

idea Integrate Nuxt Progress Bar

What problem does this feature solve?

Nuxt HTTP documentation states that this module isn't integrated yet with nuxt progress bar because of this https://github.com/sindresorhus/ky/pull/34 isn't merged. But now it has merged.

What does the proposed changes look like?

Integrate nuxt progress bar

tony19

tony19 posted a new question

http •

Using $http in asyncData with vue-property-decorator

Following the @nuxt/http usage guide, I added { $http } to the arguments of asyncData in my Nuxt TypeScript project:

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import Post from '~/models/Post'

@Component({
  components: {
    PostPreview: () => import('~/components/PostPreview.vue')
  },
  async asyncData({ $http }) {
    const { data } = await $http.get(`https://my-api/posts`)
    return {
      posts: data
    }
  }
})
export default class FeedPage extends Vue {
  posts: Post[] = []
}
</script>

but it causes a TypeScript error:

Property '$http' does not exist on type 'Context'.

Screen Shot 2019-05-28 at 10.12.46 AM.png

Screen Shot 2019-05-28 at 10.14.56 AM.png