GithubHelp home page GithubHelp logo

Setting cookie options about strapi HOT 7 CLOSED

nuxt-modules avatar nuxt-modules commented on May 28, 2024 2
Setting cookie options

from strapi.

Comments (7)

dubem-design avatar dubem-design commented on May 28, 2024 1

Please also expose options to set "TOKEN_KEY" name, one might not want to use "strapi_jwt"

from strapi.

atle-granlund avatar atle-granlund commented on May 28, 2024

I am very new to this so I might be wrong but I think you have to set your security settings for headers at server side.

They are are off by default.
https://strapi.io/documentation/v3.x/concepts/middlewares.html#configuration-and-activation.

Then nuxt/strapi module will follow the API rules.

from strapi.

Atinux avatar Atinux commented on May 28, 2024

I think we will need to expose the cookie options in the config so they can be given here: https://github.com/nuxt-community/strapi-module/blob/c88ff781dc44ecbaa58ca1c1e63b770662b91669/lib/plugin.js#L166

from strapi.

adamkhan avatar adamkhan commented on May 28, 2024

Hello, two months later and I still can't get this to work. I've tried adding cors and sessions middleware options to Strapi's /config/middleware.js, tried installing the @nuxtjs/proxy module — none of the above stop my cookie from being out-of-date the moment it's set.

Is it Strapi or Nuxt's Strapi module that sets the cookie? Might setting Samesite to Lax be a solution? How to do that?

from strapi.

adamkhan avatar adamkhan commented on May 28, 2024

@atle-granlund, thanks for the suggestion. In Strapi I set config/middleware.js to:

module.exports = {

  settings: {
	  cors: {
		  enabled: false
	  },
	  session: {
		  enabled: true
	  },
  }
};

But this did not help. As soon as I refresh my console tells me:

Cookie “strapi_jwt” has been rejected because it is already expired.

from strapi.

adamkhan avatar adamkhan commented on May 28, 2024

I only have this problem when Nuxt is running in Production mode — Development mode handles cookies for Strapi just fine,

from strapi.

adamkhan avatar adamkhan commented on May 28, 2024

Turns out the problem was using nuxt-fontawesome instead of @nuxtjs/fontawesome! I've no idea why but making this change solved the issue, at least for me.

from strapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.