Why is every request redirected to index.html

Hi all,

In a project with angular, scully and Netlify CMS, I’m struggling with the redirect system of Netlify. I don’t understand the following:

I have removed all the redirects in toml.yaml. Also I don’t have a _redirects file. So there should not be any redirects in play. The build output confirms that: " No redirect rules processed"

However, every single request is catched by the index.html.
In other projects with Nuxt, if I request a non existing page I get a 404 page served by Netlify. But in this angular/scully project I don’t get any Netlify 404.

The response code of the non-exisitent page request are indeed responded with a 404 response code, but also with the html from index.html. So I think it’s the 404 page of angular being returened.

What I want in the end is a admin.html with Netlify CMS, but when adding a redirect from /admin to admin.html, that also is being served by index.html. To get this working I wanted a very basic starting point without any redirects at all. Is there a setting I missed that makes the index.html the frontcontroller for all requests? Or how can I debug this further?

hi there william, sounds like you had redirects in place at some point. is that true?

can you also tell me the name (or API ID, safe to share) of your site so I can take a look?

Hi Perry,

Thanks for taking the time to look into this. The name is: bornemannen. And you are correct. At some point in the beginning I had a redirect rule that redirected everything to index.html, but that gave problems with enabling the Git gateway, see: Angular handles .netlify url's

Hi, @_william. I checked this site and I get the HTML for your /404.html file for any paths that don’t exist:

$ curl --compressed -sv https://bornemannen.netlify.app/not-a-valid-path
*   Trying 54.241.246.27...
* TCP_NODELAY set
* Connected to bornemannen.netlify.app (54.241.246.27) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=Netlify, Inc; CN=*.netlify.app
*  start date: Feb 15 00:00:00 2022 GMT
*  expire date: Mar  2 23:59:59 2023 GMT
*  subjectAltName: host "bornemannen.netlify.app" matched cert's "*.netlify.app"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS Hybrid ECC SHA384 2020 CA1
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fa8c4808200)
> GET /not-a-valid-path HTTP/2
> Host: bornemannen.netlify.app
> User-Agent: curl/7.64.1
> Accept: */*
> Accept-Encoding: deflate, gzip
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 404
< age: 1
< cache-control: public, max-age=0, must-revalidate
< content-encoding: gzip
< content-type: text/html; charset=utf-8
< date: Tue, 01 Mar 2022 02:49:59 GMT
< etag: 1644483490-ssl-df
< server: Netlify
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< vary: Accept-Encoding
< x-nf-request-id: 01FX1P4VXZV0X3B21EPZ2DGDK2
<
<!DOCTYPE html><html lang="en"><head>
    <meta charset="utf-8">
    <title>De Bornemannen</title>
    <base href="/">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="apple-touch-icon" sizes="180x180" href="/assets/favicon/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon/favicon-16x16.png">
    <link rel="manifest" href="/assets/favicon/site.webmanifest">

    <link rel="preconnect" href="https://fonts.gstatic.com">
    <style type="text/css">@font-face{font-family:'Bodoni Moda';font-style:normal;font-weight:400;font-display:swap;src:url(https://fonts.gstatic.com/s/bodonimoda/v7/aFT67PxzY382XsXX63LUYL6GYFcan6NJrKp-VPjfJMShrpsGFUt8oU7a8Il4snrJcwDiodAY.woff) format('woff');unicode-range:U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;}@font-face{font-family:'Bodoni Moda';font-style:normal;font-weight:400;font-display:swap;src:url(https://fonts.gstatic.com/s/bodonimoda/v7/aFT67PxzY382XsXX63LUYL6GYFcan6NJrKp-VPjfJMShrpsGFUt8oU7a8Id4snrJcwDioQ.woff) format('woff');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}</style>
    <!-- src/index.html -->
    <script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
  <style>@import url(https://fonts.googleapis.com/css2?family=Chelsea+Market&family=DM+Sans:ital,wght@0,400;:root{--blue:#007bff;--indigo:#6610f2;--purple:#6f42c1;--pink:#e83e8c;--red:#dc3545;--orange:#fd7e14;--yellow:#ffc107;--green:#28a745;--teal:#20c997;--cyan:#17a2b8;--white:#fff;--gray:#6c757d;--gray-dark:#343a40;--primary:#007bff;--secondary:#6c757d;--success:#28a745;--info:#17a2b8;--warning:#ffc107;--danger:#dc3545;--light:#f8f9fa;--dark:#343a40;--breakpoint-xs:0;--breakpoint-sm:576px;--breakpoint-md:768px;--breakpoint-lg:992px;--breakpoint-xl:1200px;--font-family-sans-serif:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-family-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;}*,:after,:before{box-sizing:border-box;}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-weight:400;line-height:1.5;color:#212529;text-align:left;}@page {size:a3;}body{min-width:992px!important;}</style><link rel="stylesheet" href="styles.fac5383864295f8c5f5b.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.fac5383864295f8c5f5b.css"></noscript></head>
  <body>
    <app-root></app-root>
    <script>
      if (window.netlifyIdentity) {
        window.netlifyIdentity.on("init", user => {
          if (!user) {
            window.netlifyIdentity.on("login", () => {
              document.location.href = "/admin/";
            });
          }
        });
      }
    </script>
  <script src="runtime.7bf521b2a5af24f3ed3b.js" defer></script><script src="polyfills.f50f93cae9a447cf19d5.js" defer></script><script src="scripts.8a473239f46c70a7d0f7.js" defer></script><script src="main.a5a2dbeacc50d86d0d74.js" defer></script>

* Connection #0 to host bornemannen.netlify.app left intact
</body></html>* Closing connection 0

This is the default 404 behavior mentioned in the documentation, quoted below:

You can set up a custom 404 page for all paths that don’t resolve to a static file. This doesn’t require any redirect rules. If you add a 404.html page to your site, it will be picked up and displayed automatically for any failed paths.

So, this isn’t redirecting to /index.html but to /404.html. You can download the deploy to compare the HTML sent to the HTML in /404.html.

If there are other questions, please let us know.