-
Notifications
You must be signed in to change notification settings - Fork 81
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
feat: add cookie config #208
Conversation
Hi @luke-z, First of all, thank you for this PR! Back in the To change this behaviour, I would rather only have a |
Hello @benjamincanac Thank you for the feedback! I changed the config from expires to cookie as you suggested and updated the docs. |
src/types/index.ts
Outdated
@@ -1,3 +1,4 @@ | |||
import { CookieOptions } from 'nuxt3/dist/app/composables/cookie' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielroe To confirm with you, is this the right way to get this type? Shouldn't it be #app/composables/cookie
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried using the type without any import, this results in the build error
error TS4033: Property 'cookie' of exported interface has or is using private name 'CookieOptions'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With nuxt3
import it resulted into a build error, I've updated it with the #app
alias but we still have a warning on build:
WARN Inlining implicit external #app/composables/cookie
'#app/composables/cookie' is imported by src/types/index.ts, but could not be resolved – treating it as an external dependency
I'm gonna wait for Daniel validation on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put #app in the build.config.ts, which seems to resolve the problem (I am not familiar with unbuild)
externals: ['@nuxt/kit', '@nuxt/schema', 'vue', '#app']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #app
alias won't work in published libraries, unless those library source files are added in the end user's tsconfig.json
include array. So you'll need to use 'nuxt3/dist/app/composables/cookie
but add nuxt3
to your externals list in your build config.
(This is a unique point for types. For any runtime import of the cookie composable we should import directly from #app
or #imports
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @danielroe, it works perfectly!
Next time I definitely need to go for lint & build, just checking if it works while in dev mode is not a good approach... Thank you for the improvements & fixes!
|
As this is my first open source pr, I hope I did everything well :)
Types of changes
Description
Currently the strapi token is saved as a session cookie which expires as soon as the browser is closed.
Back in v0, there was a config option which allowed to set the expires property.
With this pull request I have added such a feature.
Checklist: