CORS issue from Shared Slice

This has also just started occurring for our site this afternoon, Ive tried following a few of the other guides on here to fix the issue but so far none have worked. When i click through the error i get a 'Prismic-Ref missing from header' message - however, i can see the prismic-ref: in the request headers

From what i can tell this is/was also being looked at here - Request header field prismic-ref is not allowed by Access-Control-Allow-Headers in preflight response - #16 by sbaughman - it looks to be fairly intermittent so im not sure if a permanent fix has been implemented yet, any updates or help from the prismic team would be much appreciated

corsError

@Phil
Hey Phil, this still isnt working for me both here https://cassette-prismic-nuxt-staging.herokuapp.com/
and on my local version. Ive republisjed all documents across the site and for local reduced the query significantly to test whether that was the issue but still no dice.

We haven't deployed any changes to https://cassette-prismic-nuxt-staging.herokuapp.com/ in the last week so im still fairly sure this is the same issue experienced above

Original query:
{
page(uid:"homepage", lang:"en-gb"){
hype_reel
page_primary_title__h1_
page_primary_title_sidebar_text
work_types {
work_type_image
work_type_title
image_direction
image_offset
custom_path
}
work_types_sidebar_text
case_studies_sidebar_text
}
page_our_clients(uid:"our-clients", lang:"en-gb"){
page_title
page_description
_meta {
id
uid
}
}
allWorks(tags:"Featured"){
edges{
node{
_meta {
uid
id
}
work_title
header_image
work_content
}
}
}
allClients(tags:"Featured"){
edges{
node{
meta {
uid
id
}
client_name
client_logo
}
}
}
}
Reduced Query:
{
page(uid:"homepage", lang:"en-gb"){
hype_reel
page_primary_title__h1

page_primary_title_sidebar_text
work_types {
work_type_image
work_type_title
image_direction
image_offset
custom_path
}
work_types_sidebar_text
case_studies_sidebar_text
}
}

Oddly when i use the graphQL Api tool to check the query i get no response from either

https://cassette-prismic-nuxt.prismic.io/graphql

Hi Tyrone,

Your issue is related to adding CDN in your GraphQL endpoint which isn't necessary:

If remove that and define it as https://cassette-prismic-nuxt.prismic.io/graphql then this should work.

Thanks.

Hey Phil, Im not calling the cdn on any graphQL queries so not sure how thats getting pulled into the URL, the only references i can see in my code to a cdn link is 'https://cassette-prismic-nuxt.cdn.prismic.io/api/v2' in the nuxt.config file and sm.json - both of which have been there from the beginning of the project and are in the documentation for nuxt projects - nuxtjs-website/nuxt.config.js at master · prismicio/nuxtjs-website · GitHub

After removing these references from local I still receive the same CORs error.

Im not convined thats the problem anyway as again, the non local version of our site that hasnt had any changes deployed to it for weeks, and was previously working up until wednesday, isnt

this is my graphQl config file for reference
graphQLConfig

Yeah, it's strange that it added the CDN parameter to your endpoint.

The CDN link 'https://cassette-prismic-nuxt.cdn.prismic.io/api/v2' in your nuxt.config and sm.json files are used for the prismic-nuxt module and Slice Machine respectively so if you're not using the REST API or Slice Machine you can probably remove these.

The only other thing I can think to do to resolve this is to invalidate your local cache from apollo-cache-inmemory. If that doesn't work can you send me a copy of your project so I can investigate this on my side? I'll also reach out to the team to see if they have any ideas about this.

Hey Tyrone,

I moved your posts as your issue is apparently unrelated.

It seems I've been working off of some outdated information. A GraphQL endpoint with the CDN parameter 'https://cassette-prismic-nuxt.cdn.prismic.io/graphql' is totally possible so that's not the issue. It's slso not your local cache.

It seems the issue is coming from a Shared Slice on your repository. I'm getting more information on exactly what that means and I'll get back to you shortly on this.

Thanks.

Hi again Tyrone,

So the problem that you were seeing here is that the GraphQL endpoint is broken because of an issue with SharedSlice.

When you created the SharedSlice you defined this SharedSlice's fields in snaked case, and we filter out those fields, which ends up defining an empty Slice, which is not authorised with GraphQL.

So if you can rename these fields it should work again.

We've created a PR so the API does not break in that case in the future.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.