Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-24955

Query links result in infinite redirects

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: www_lsst_io
    • Labels:
      None

      Description

      It is really nice that the search fills in the URL so it can be copied and shared, but using the URL results in a redirect loop. This can be triggered by either:
      1 doing a search and hitting the reload button in the browser
      2 clicking on this link

        Attachments

          Issue Links

            Activity

            Hide
            jsick Jonathan Sick added a comment -

            I think we've cracked this. One change that needed to be be made was in the search app to always include a trailing slash in the path (i.e. /search/?query=vault). Gatsby natively prefers trailing slashes. Before we were rewriting the browser URL with just the directory name (i.e. /search?query=vault), but that actually triggers a 301 redirect on the client.

            Second, we've modified the Fastly Varnish configuration for directory redirects to access the index.html file in the S3 bucket if the path ends with a trailing slash.

            Before, the redirect VCL was:

            if( req.url ~ "/$" ) {
              set req.url = req.url "index.html";
            } 

            The new redirect VCL is:

            if ( req.url.path ~ "/$" ) {
              set req.url = req.url.path "index.html"
            } 

            So the key parts of this are:

            • Test if the path ends with "/" rather than the whole URL. This lets us be compatible with query strings.
            • When setting the new req.url, append "index.html" to the path, which excludes the query string.

             

            Show
            jsick Jonathan Sick added a comment - I think we've cracked this. One change that needed to be be made was in the search app to always include a trailing slash in the path (i.e. /search/?query=vault) . Gatsby natively prefers trailing slashes. Before we were rewriting the browser URL with just the directory name (i.e. /search?query=vault ), but that actually triggers a 301 redirect on the client. Second, we've modified the Fastly Varnish configuration for directory redirects to access the index.html file in the S3 bucket if the path ends with a trailing slash. Before, the redirect VCL was: if ( req.url ~ "/$" ) { set req.url = req.url "index.html" ; } The new redirect VCL is: if ( req.url.path ~ "/$" ) { set req.url = req.url.path "index.html" } So the key parts of this are: Test if the path ends with "/" rather than the whole URL. This lets us be compatible with query strings. When setting the new req.url, append "index.html" to the path, which excludes the query string.  

              People

              Assignee:
              jsick Jonathan Sick
              Reporter:
              krughoff Simon Krughoff
              Watchers:
              Jonathan Sick, Simon Krughoff
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.