-1

I hosted my project's staging using netlify and I came across an issue that netlify seems to only host Home.jsx file for some reason even though I have set up react routing in my project:

import "./App.css";
import { Routes, Route } from "react-router-dom";
import Home from "./components/LandingPages/Home";
import Partner from "./components/LandingPages/Partner";
import Login from "./components/LoginAndRegister/Login";
import Register from "./components/LoginAndRegister/Register";

function App() {
  return (
    <Routes>
      <Route path="/" element={<Home />} />
      <Route path="/partner" element={<Partner />} />
      <Route path="/login" element={<Login />} />
      <Route path="/register" element={<Register />} />
    </Routes>
  );
}

export default App;
5
  • Netlify hosts the entire app. What exactly is the issue or problem you face? Commented Oct 30, 2023 at 19:21
  • @DrewReese I can not access any other url rather than just a main domain, can't open my /partner page i have for example. Commented Oct 30, 2023 at 19:56
  • Can you clarify what exactly you mean by "can't open a page"? Why aren't you able to access your site? Are there any errors in the console or network tab in the browser? Can you share how you have configured the hosting service? Commented Oct 30, 2023 at 20:19
  • Hi again @DrewReese, not sure what was the issue but I have figured out how to fix it. I created a netlify.toml file in root folder and added this into it: [[redirects]] from = "/*" to = "index.html" status = 200 Commented Oct 30, 2023 at 20:43
  • I see, so basically this: create-react-app.dev/docs/deployment/#netlify Commented Oct 30, 2023 at 20:48

1 Answer 1

0

I created a netlify.toml file in root folder and added this into it:

[[redirects]]
from = "/*"
to = "index.html"
status = 200
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.