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

Globally set options.Credentials #92

darthf1 opened this issue Mar 31, 2020 · 5 comments

Globally set options.Credentials #92

darthf1 opened this issue Mar 31, 2020 · 5 comments


Copy link

darthf1 commented Mar 31, 2020

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?

@cmty cmty bot closed this as completed Mar 31, 2020
@cmty cmty bot added the cmty:question label Mar 31, 2020
Copy link

cmty bot commented Mar 31, 2020

This issue as been imported as question since it does not respect http issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at

Copy link

wildan2711 commented May 21, 2020

Did you find solution? I need this too.

Copy link

darthf1 commented May 28, 2020

No solution unfortunately

Copy link

desislavsd commented Aug 4, 2020

You may create a plugin and add the following:

export default ( { $http } ) => {

    $http._defaults.credentials = 'include'; 

Copy link

notiv-nt commented May 13, 2021

+1 for the comment above, and don't forget to add plugin to the nuxt.config.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

4 participants