question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fallback not working.

See original GitHub issue

Issue Summary

Server is not redirecting to the 404 page if the page does not exist. Instead it shows an ugly s3 404 error: image Our getStaticPaths hook look like this:

export async function getStaticPaths() {
  let paths = []
  let allVenues
  let errors
  const fallback = true //If fallback is false, then any paths not returned by getStaticPaths will result in a 404 page. SETTING TO TRUE WILL ENABLE US TO QUERY IN REAL TIME IF NEW PATH COMES TO LIGHT...

  const perPage = 100
  let done = false
  for (let page = 0; !done && !errors; page++) {
    const { error, venues } = await getVenuesSSR({ page, perPage })
    allVenues = allVenues ? [...allVenues, ...venues] : venues
    done = venues?.length === 0
    errors = error ? error : undefined
    errors = venues === undefined && errors === undefined ? 'error' : errors
  }

  //  venues/seatgeek/venue/{seatgeekVenueId}/parking
  //  venues/[city-name]/[venueid]/[venue-name]/parking
  if (errors || !allVenues) {
    // paths = []
    // TODO: SENTRY LOG
  } else {
    const seatGeekpaths = allVenues
      .filter(venueWithGoodStatus => venueWithGoodStatus.status !== 'hidden')
      .filter(venueWithSeatGeekId => venueWithSeatGeekId.seatGeekId !== null)
      .map(venue => {
        return {
          params: {
            slug: [
              'seatgeek',
              'venue',
              venue?.seatGeekId?.toString(),
              'parking',
            ],
          },
        }
      })

    const allpaths = allVenues
      .filter(venueWithGoodStatus => venueWithGoodStatus.status !== 'hidden')
      .map(venue => {
        const cityNameEncoded = getEncodedCityNameFromVenue({ venue })
        const venueNameEncoded = getEncodedVenueNameFromVenue({ venue })

        return {
          params: {
            slug: [
              cityNameEncoded,
              venue?.id?.toString(),
              venueNameEncoded,
              'parking',
            ],
          },
        }
      })
    paths = [...seatGeekpaths, ...allpaths]
  }

  return {
    fallback,
    paths,
  }
}

And we have placed a check inside render like this: image Also if i set fallback: false it shows exact same error.

Actual behavior

Whenever i miss spell static page it throws s3 error.

Expected behavior

It should show loading or custom 404 page.

Screenshots/Code/Configuration/Logs

serverless.yml looks like this: image

Versions

If someone could help it would be great.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
Talhafayyaz11commented, Aug 2, 2021

The problem is that it is not falling back to given fallback URL when CloudFront hits wrong s3 key.

0reactions
Talhafayyaz11commented, Aug 2, 2021

@dphang thank you. You are a super star!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring cloud openfeign 3.0.1 fallback not being triggered
I'm using the version 3.0.1 of spring-cloud-starter-openfeign and I'm having problems with the fallback implementation. Seems it's not being triggered if ...
Read more >
Fallbacks with Spring Cloud Feign - Arnold Galovics
Today, I'll show you how to improve the behavior of your app with fallbacks when a service is crashing, or unavailable either due...
Read more >
K55621624: Fallback to local accounts not working - AskF5
Local accounts are not authenticating with remote authentication configured and 'Fallback to Local' enabled. Environment.
Read more >
Localization fallback not working - Unity Forum
Hi, today I'm trying to use localization package, but having some issues, when I'm trying to use var op =...
Read more >
Fallback for with Feign does not works · Issue #560 - GitHub
Hi, a fallback must implement the interface MyFeignClient . Can you show me your Interface?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found