Expired Token - access token 403 error on some page visits, Safari

Thanks Phil,

This happens on our SSR production site, the site isn't live yet but the near-live test also throws this error.
Unfortunately static generated isn't really an option given the projects phase 2 plans.

OK, normally it's still not an issue in SSR unless you're doing a lot of contents updates at the same time as I imagine you're doing now.

All the same I don't want to leave you with an issue like this so I'm reaching out to my team to try and find a solution for you.

Thanks Phil,

We have built in a fallback which forces a full page reload if refs are different. Obviously this isn't ideal as it leads to a longer load time to the new page, but at least removes the 403 error.

We put this inside our layouts/default.vue

async middleware ({ store, params, $config, redirect, route, $prismic, $axios }) {
  const currentMasterRef = $prismic.api.masterRef.ref
  const freshMasterRef = await $axios.get('https://[repo].cdn.prismic.io/api/v2')
  if (process.client && currentMasterRef !== freshMasterRef.data.refs[0].ref) {
    redirect($config.baseURL + route.fullPath)
  }
}

I was going to suggest something similar for the time being, though not as well coded as your example :laughing:

I've made the team aware of this and they'll investigate further.

1 Like

This is being tracked as an open feature request.

If you have another use-case for this feature, you can 'Flag' this topic to reopen. Please use the :heart: button to show your support for the feature and check out our Feature Request Guidelines.