Page Not Found...error 404

Hi, I when I try to access this route:

window.location = “/admin”;

I get an error (in my local it works fine):

Page Not Found

Looks like you’ve followed a broken link or entered a URL that doesn’t exist on this site.

Back to our site

If this is your site, and you weren’t expecting a 404 for this path, please visit Netlify’s …

*SITE NAME: https://jolly-bell-ad79e8.netlify.app/

Thank you very much for your help guys.

Hi there,

Did you see this guide yet? This is the best place to start for “Page Not Found” issues.

If you are still seeing issues after following the troubleshooting steps in this guide, please let us know!

The 404 code means that the server was unable to locate the files you were looking for via GET request.

You might try adding the text/javascript type to your tags, as the examples for google maps api do.

ie:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>

As far as the second problem you encountered, it looks like the url you passed into the getData() function was invalid.

1 Like

Thank you very much Thomas, I can’t know where to put the tags in the code:

    import { useState } from "react";

    const InputFood = () => {
      const [name, setName] = useState("");

      const onSubmitForm = async (e) => {
      
        e.preventDefault();
        try {
          const body = { name };
         
          const response = await fetch(
            "https://backend-challenge-ts.herokuapp.com/",
            {
              method: "POST",
              headers: { "Content-Type": "application/json" },
              body: JSON.stringify(body),
            }
          );

          window.location = "/admin";

     
        } catch (err) {
          
        }
      };

      return (
        <>
          <h1 className="text-center mt-5"> Food Database</h1>
          <form className="d-flex mt-5" onSubmit={onSubmitForm}
          >
            <input
              type="text/javascript"
              className="form-control"
              value={name}
              onChange={(e) => setName(e.target.value)}
            />
            <button className="btn btn-success">Add</button>
          </form>
        </>
      );
    };

    export default InputFood;


Hi, @JGPcode. I believe your site is doing client side routing and, because of this, it needs the following “single-page application” (or SPA) redirect rule to work:

/*    /index.html   200

There is more about this in our documentation here:

https://docs.netlify.com/routing/redirects/rewrites-proxies/#history-pushstate-and-single-page-apps

If that doesn’t resolve the issue or if there are any questions about how to make that rule, please let us know.