Token is not properly retrieved on server side.
Version
@nuxtjs/strapi: 1.1.0-27369286.5893b15 nuxt: 3.0.0-27374259.21b664c
Steps to reproduce
In a page I'm trying to retrieve objects from strapi like this:
<script setup>
const strapi = useStrapi4();
const objects= await strapi.find("objects");
...
</script>
What is Expected?
Objects are retrieved.
What is actually happening?
Request fails because the token is not properly retrieved on the server side.
https://github.com/nuxt-community/strapi-module/blob/7e909c78b81359e55bef18585608cbe51bcdbdf5/src/runtime/composables/useStrapiToken.ts#L8
If we change it to:
if (!nuxtApp.ssrContext && nuxtApp._cookies.strapi_jwt) {
return nuxtApp._cookies.strapi_jwt
}
it works.
Hey @dsciamma
Have you tried using useAsyncData to fetch your data on the server-side?
We added an example in the documentation: https://strapi.nuxtjs.org/advanced#async-data
My bad, indeed, using useAsyncData it works properly. 👍