Route Resolver reach the maximum URL length
Versions
- Operating System: Darwin
- Node Version: v18.18.2
- Nuxt Version: 3.8.2
- CLI Version: 3.10.0
- Nitro Version: 2.8.1
- Package Manager: [email protected]
- Builder: -
- User Config: telemetry, vite, runtimeConfig, css, modules, site, sitemap, googleFonts, gtm, tailwindcss, prismic, i18n, postcss, devtools
- Runtime Modules: @nuxt/[email protected], @nuxtjs/[email protected], @zadigetvoltaire/[email protected], @nuxtjs/[email protected], @vueuse/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], [email protected], [email protected], @nuxt/[email protected], [email protected]
- Build Modules: -
details
I know that "The maximum URL length for requests to the Document API is 2048 characters" but the problem is that i reach this max length with the route resolver. I think that the module merge the homepage getSingle() fetch with the Route Resolver and create a big URL.
I have the following Client.ts file:
import type { Content } from '@prismicio/client'
import { createClient } from '@prismicio/client'
export default createClient<Content.AllDocumentTypes>('smartpricing', {
routes: [
// homepage
{
type: 'home-page',
path: '/:lang'
},
// pricing
{
type: 'pricing',
path: '/:lang/pricing'
},
// how-much
{
type: 'how_much',
lang: 'it',
path: '/:lang/pricing/quanto-costa'
},
{
type: 'how_much',
lang: 'de',
path: '/:lang/pricing/quanto-costa-test'
},
{
type: 'how_much',
lang: 'en',
path: '/:lang/pricing/how-much'
},
// chi-siamo
{
type: 'who-we-are',
lang: 'it',
path: '/:lang/chi-siamo'
},
{
type: 'who-we-are',
lang: 'de',
path: '/:lang/uber-uns'
},
{
type: 'who-we-are',
lang: 'en',
path: '/:lang/mission'
},
// how-it-works
{
type: 'how_it_works',
lang: 'it',
path: '/:lang/come-funziona'
},
{
type: 'how_it_works',
lang: 'de',
path: '/:lang/produkt'
},
{
type: 'how_it_works',
lang: 'en',
path: '/:lang/how-it-works'
},
// press-kit
{
type: 'press_kit',
lang: 'it',
path: '/:lang/presskit-download'
},
{
type: 'press_kit',
lang: 'de',
path: '/:lang/presskit-herunterladen'
},
{
type: 'press_kit',
lang: 'en',
path: '/:lang/presskit-download'
},
// partner-archive
{
type: 'partner_archive',
path: '/:lang/partner'
},
// blog-archive
{
type: 'blog_archive',
lang: 'it',
path: '/:lang/blog/archivio/1'
},
{
type: 'blog_archive',
lang: 'de',
path: '/:lang/blog/archiv/1'
},
{
type: 'blog_archive',
lang: 'en',
path: '/:lang/blog/archive/1'
},
// blog-category
{
type: 'blog_category',
lang: 'it',
path: '/:lang/blog/archivio/1/:uid'
},
{
type: 'blog_category',
lang: 'de',
path: '/:lang/blog/archiv/1/:uid'
},
{
type: 'blog_category',
lang: 'en',
path: '/:lang/blog/archive/1/:uid'
},
// blog-post
{
type: 'blog-post',
path: '/:lang/blog/:uid'
},
// guide-archive
{
type: 'guide_archive',
lang: 'it',
path: '/:lang/guide/archivio/1'
},
{
type: 'guide_archive',
lang: 'de',
path: '/:lang/unsere-pdf-leitfaden/archiv/1'
},
{
type: 'guide_archive',
lang: 'en',
path: '/:lang/guides/archive/1'
},
// guide-category
{
type: 'guideCategory',
lang: 'it',
path: '/:lang/guide/archivio/1/:uid'
},
{
type: 'guideCategory',
lang: 'de',
path: '/:lang/unsere-pdf-leitfaden/archiv/1/:uid'
},
{
type: 'guideCategory',
lang: 'en',
path: '/:lang/guides/archive/1/:uid'
},
// guide
{
type: 'guide',
lang: 'it',
resolvers: {
category: 'category'
},
path: '/:lang/guide/:uid'
},
{
type: 'guide',
lang: 'de',
resolvers: {
category: 'category'
},
path: '/:lang/unsere-pdf-leitfaden/:uid'
},
{
type: 'guide',
lang: 'en',
resolvers: {
category: 'category'
},
path: '/:lang/guides/:uid'
},
// webinar archive
{
type: 'webinar_archive',
lang: 'it',
path: '/:lang/webinar-formazione-hotel'
},
// webinar
{
type: 'webinar',
lang: 'it',
path: '/:lang/webinar-formazione-hotel/:uid'
},
// case-study-archive
{
type: 'case_study_archive',
lang: 'it',
path: '/:lang/case-study/archivio/1'
},
{
type: 'case_study_archive',
lang: 'de',
path: '/:lang/case-study/archiv/1'
},
{
type: 'case_study_archive',
lang: 'en',
path: '/:lang/case-study/archive/1'
},
// NOTE: case-study category managed in app/prismic/linkResolver
// case-study
{
type: 'case_study',
path: '/:lang/case-study/:uid'
},
// smartpaying
{
type: 'smartpaying',
path: '/:lang/smartpaying'
},
// smartpricing_vs_competitor_analysis
{
type: 'smartpricing_vs_competitor_analysis',
lang: 'it',
path: '/:lang/smartpricing-vs-guardo-i-competitor'
},
{
type: 'smartpricing_vs_competitor_analysis',
lang: 'de',
path: '/:lang/smartpricing-vs-mitbewerber-beobachten'
},
{
type: 'smartpricing_vs_competitor_analysis',
lang: 'en',
path: '/:lang/smartpricing-vs-competitor-analysis'
},
// smartpricing_vs_competitor_software
{
type: 'smartpricing_vs_competitor_software',
lang: 'it',
path: '/:lang/smartpricing-vs-software-competitor'
},
{
type: 'smartpricing_vs_competitor_software',
lang: 'de',
path: '/:lang/smartpricing-vs-software-konkurrenz'
},
{
type: 'smartpricing_vs_competitor_software',
lang: 'en',
path: '/:lang/smartpricing-vs-competitor-software'
},
// smartpricing_vs_fixed_price
{
type: 'smartpricing_vs_fixed_price',
lang: 'it',
path: '/:lang/smartpricing-vs-listino-fisso'
},
{
type: 'smartpricing_vs_fixed_price',
lang: 'de',
path: '/:lang/smartpricing-vs-festpreis'
},
{
type: 'smartpricing_vs_fixed_price',
lang: 'en',
path: '/:lang/smartpricing-vs-fixed-prices'
},
// smartpricing_vs_principles_of_revenue_management
{
type: 'smartpricing_vs_principles_of_revenue_management',
lang: 'it',
path: '/:lang/smartpricing-vs-applico-principi-revenue-management'
},
{
type: 'smartpricing_vs_principles_of_revenue_management',
lang: 'de',
path: '/:lang/smartpricing-vs-dynamische-preisgestaltung'
},
{
type: 'smartpricing_vs_principles_of_revenue_management',
lang: 'en',
path: '/:lang/smartpricing-vs-principles-of-revenue-management'
},
// demo_request
{
type: 'demo_request',
lang: 'it',
path: '/:lang/prova-smartpricing'
},
{
type: 'demo_request',
lang: 'de',
path: '/:lang/demo-anfordern'
},
{
type: 'demo_request',
lang: 'en',
path: '/:lang/try-smartpricing'
},
{
type: 'work_with_us',
lang: 'it',
path: '/:lang/lavora-con-noi'
},
{
type: 'work_with_us',
lang: 'de',
path: '/:lang/karriere'
},
{
type: 'work_with_us',
lang: 'en',
path: '/:lang/work-with-us'
},
{
type: 'open_positions',
lang: 'it',
path: '/:lang/lavora-con-noi/posizioni-aperte'
},
{
type: 'open_positions',
lang: 'de',
path: '/:lang/karriere/offene-stellen'
},
{
type: 'open_positions',
lang: 'en',
path: '/:lang/work-with-us/open-positions'
},
{
type: 'career',
lang: 'it',
path: '/:lang/lavora-con-noi/:uid'
},
{
type: 'career',
lang: 'de',
path: '/:lang/karriere/:uid'
},
{
type: 'career',
lang: 'en',
path: '/:lang/work-with-us/:uid'
},
// cookie declaration
{
type: 'cookie_declaration',
path: '/:lang/cookie-declaration'
},
// legal
{
type: 'legal',
path: '/:lang/legal'
},
]
})
and this code on home-page
const { data: content, error: contentError } = await useAsyncData(() => {
return client
.getSingle('home-page', {
lang: locale.value,
fetchLinks: [
'case_study.img',
'case_study.has_video',
'case_study.card_title',
'case_study.title',
'case_study.structure_location',
'case_study.features',
'case_study.subtitle',
'guide.date',
'guide.type',
'guide.title',
'guide.description',
'guide.mainImage',
'guide.category',
]
})
})
The resulting query is
https://smartpricing.cdn.prismic.io/api/v2/documents/search?q=[[at(document.type,"home-page")]]&lang=it&fetchLinks=case_study.img,case_study.has_video,case_study.card_title,case_study.title,case_study.structure_location,case_study.features,case_study.subtitle,guide.date,guide.type,guide.title,guide.description,guide.mainImage,guide.category&pageSize=1&ref=ZYHGPRIAACMA_dYD&routes=[{"type":"home-page","path":"/:lang"},{"type":"pricing","path":"/:lang/pricing"},{"type":"how_much","lang":"it","path":"/:lang/pricing/quanto-costa"},{"type":"how_much","lang":"de","path":"/:lang/pricing/quanto-costa-test"},{"type":"who-we-are","lang":"it","path":"/:lang/chi-siamo"},{"type":"who-we-are","lang":"de","path":"/:lang/uber-uns"},{"type":"who-we-are","lang":"en","path":"/:lang/mission"},{"type":"how_it_works","lang":"it","path":"/:lang/come-funziona"},{"type":"how_it_works","lang":"de","path":"/:lang/produkt"},{"type":"how_it_works","lang":"en","path":"/:lang/how-it-works"},{"type":"press_kit","lang":"it","path":"/:lang/presskit-download"},{"type":"press_kit","lang":"de","path":"/:lang/presskit-herunterladen"},{"type":"press_kit","lang":"en","path":"/:lang/presskit-download"},{"type":"partner_archive","path":"/:lang/partner"},{"type":"blog_archive","lang":"it","path":"/:lang/blog/archivio/1"},{"type":"blog_archive","lang":"de","path":"/:lang/blog/archiv/1"},{"type":"blog_archive","lang":"en","path":"/:lang/blog/archive/1"},{"type":"blog_category","lang":"it","path":"/:lang/blog/archivio/1/:uid"},{"type":"blog_category","lang":"de","path":"/:lang/blog/archiv/1/:uid"},{"type":"blog_category","lang":"en","path":"/:lang/blog/archive/1/:uid"},{"type":"blog-post","path":"/:lang/blog/:uid"},{"type":"guide_archive","lang":"it","path":"/:lang/guide/archivio/1"},{"type":"guide_archive","lang":"de","path":"/:lang/unsere-pdf-leitfaden/archiv/1"},{"type":"guide_archive","lang":"en","path":"/:lang/guides/archive/1"},{"type":"guideCategory","lang":"it","path":"/:lang/guide/archivio/1/:uid"},{"type":"guideCategory","lang":"de","path":"/:lang/unsere-pdf-leitfaden/archiv/1/:uid"},{"type":"guideCategory","lang":"en","path":"/:lang/guides/archive/1/:uid"},{"type":"guide","lang":"it","resolvers":{"category":"category"},"path":"/:lang/guide/:uid"},{"type":"guide","lang":"de","resolvers":{"category":"category"},"path":"/:lang/unsere-pdf-leitfaden/:uid"},{"type":"guide","lang":"en","resolvers":{"category":"category"},"path":"/:lang/guides/:uid"},{"type":"webinar_archive","lang":"it","path":"/:lang/webinar-formazione-hotel"},{"type":"webinar","lang":"it","path":"/:lang/webinar-formazione-hotel/:uid"},{"type":"case_study_archive","lang":"it","path":"/:lang/case-study/archivio/1"},{"type":"case_study_archive","lang":"de","path":"/:lang/case-study/archiv/1"},{"type":"case_study_archive","lang":"en","path":"/:lang/case-study/archive/1"},{"type":"case_study","path":"/:lang/case-study/:uid"},{"type":"smartpaying","path":"/:lang/smartpaying"},{"type":"smartpricing_vs_competitor_analysis","lang":"it","path":"/:lang/smartpricing-vs-guardo-i-competitor"},{"type":"smartpricing_vs_competitor_analysis","lang":"de","path":"/:lang/smartpricing-vs-mitbewerber-beobachten"},{"type":"smartpricing_vs_competitor_analysis","lang":"en","path":"/:lang/smartpricing-vs-competitor-analysis"},{"type":"smartpricing_vs_competitor_software","lang":"it","path":"/:lang/smartpricing-vs-software-competitor"},{"type":"smartpricing_vs_competitor_software","lang":"de","path":"/:lang/smartpricing-vs-software-konkurrenz"},{"type":"smartpricing_vs_competitor_software","lang":"en","path":"/:lang/smartpricing-vs-competitor-software"},{"type":"smartpricing_vs_fixed_price","lang":"it","path":"/:lang/smartpricing-vs-listino-fisso"},{"type":"smartpricing_vs_fixed_price","lang":"de","path":"/:lang/smartpricing-vs-festpreis"},{"type":"smartpricing_vs_fixed_price","lang":"en","path":"/:lang/smartpricing-vs-fixed-prices"},{"type":"smartpricing_vs_principles_of_revenue_management","lang":"it","path":"/:lang/smartpricing-vs-applico-principi-revenue-management"},{"type":"smartpricing_vs_principles_of_revenue_management","lang":"de","path":"/:lang/smartpricing-vs-dynamische-preisgestaltung"},{"type":"smartpricing_vs_principles_of_revenue_management","lang":"en","path":"/:lang/smartpricing-vs-principles-of-revenue-management"},{"type":"demo_request","lang":"it","path":"/:lang/prova-smartpricing"},{"type":"demo_request","lang":"de","path":"/:lang/demo-anfordern"},{"type":"demo_request","lang":"en","path":"/:lang/try-smartpricing"},{"type":"work_with_us","lang":"it","path":"/:lang/lavora-con-noi"},{"type":"work_with_us","lang":"de","path":"/:lang/karriere"},{"type":"work_with_us","lang":"en","path":"/:lang/work-with-us"},{"type":"open_positions","lang":"it","path":"/:lang/lavora-con-noi/posizioni-aperte"},{"type":"open_positions","lang":"de","path":"/:lang/karriere/offene-stellen"},{"type":"open_positions","lang":"en","path":"/:lang/work-with-us/open-positions"},{"type":"career","lang":"it","path":"/:lang/lavora-con-noi/:uid"},{"type":"career","lang":"de","path":"/:lang/karriere/:uid"},{"type":"career","lang":"en","path":"/:lang/work-with-us/:uid"},{"type":"cookie_declaration","path":"/:lang/cookie-declaration"},{"type":"legal","path":"/:lang/legal"}]
As you can see it's an union between .getSingle('home-page') and Route Resolver.
I need to add another page on Route Resolver but it throw this error:
413 ERROR The request could not be satisfied. Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner. If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
How can i solve? Thanks!
Hi there, thanks for your report and sorry for the delay getting back to you.
I've made sure to report this issue internally. Unfortunately, this platform limit is hard to work around and we're thinking about other solutions to routing that don't involve rules being forwarded as part of the URL.
A temporary solution I can see could be to filter rules not related to the current language being queried (which could have some unwanted side effects if an English page tries to link to an Italian one for example)
This could look something like this:
import type { Content } from '@prismicio/client'
import { createClient } from '@prismicio/client'
export default createClient<Content.AllDocumentTypes>('smartpricing', {
routes: [ /* ... */ ],
fetch(stringURL, options) {
const url = new URL(stringURL as string)
const lang = url.searchParams.get('lang')
const routes = url.searchParams.get('routes')
if (lang && routes) {
// Alternatively, to avoid parsing a JSON here you could get the full route resolver
// from a constant set above in this file
const routeResolver = JSON.parse(routes)
const localizedRouteResolver = routeResolver.filter((rule) => {
// Only current lang or documents without langs
return rule.lang === lang || !route.lang
})
url.searchParams.set('routes', JSON.stringify(localizedRouteResolver))
}
return fetch(url.toString(), options)
}
})