Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 16420

Cloudflare Pages / React build - Routing not working

$
0
0

So since tomorrow (i did not changed anything on the Routing) it doesnt work anymore, not even locally, and not on cloudflare pages.

Main.tsx

import React from 'react'import ReactDOM from 'react-dom/client'import { Routes } from './Routes.tsx'import './style.css'ReactDOM.createRoot(document.getElementById('root')!).render(<React.StrictMode><Routes /></React.StrictMode>,)

Routes.tsx

import { RouterProvider, createBrowserRouter } from "react-router-dom"import App from "./App"import { NotFound } from "./pages/NotFound"import Reports from "./reports"import { ReportNotFound } from "./pages/ReportNotFound"import Home from "./pages/Home"import { ErrorPage } from "./pages/ErrorPage"import { Queue } from "./pages/Pending"import { SnackbarProvider } from "notistack"export const ANDRoutes = [    {        path: '/',        index: true,        element: <Home />    },    {        path: "/upload",        element: <Home />    },    {        path: '/reports/:sha256/:dest',        element: <Reports />    },    {        path: '/reports/:sha256/:dest/:subdest',        element: <Reports />    },    {        path: '/reports/:sha256',        element: <Reports />    },    {        path: '/help/ReportNotFound',        element: <ReportNotFound />    },    {        path: "/queue/:sha256",        element: <Queue />    },    {        path: '*',        element: <NotFound />    }]const router = createBrowserRouter([    {        path: '/',        element: <App />,        children: ANDRoutes,        errorElement: <ErrorPage />    }])export function Routes() {    return (<><SnackbarProvider maxSnack={3} preventDuplicate={true} ><RouterProvider router={router} /></SnackbarProvider></>    )}

And the important part App.tsx

import { Box } from "@mui/material"import { Outlet } from "react-router-dom"function App() {  return (<Box><Outlet/></Box>  )}export default App

When i replace "Outlet" with static it will show me my home, but if i use Outletit just shows me an blank page, and none of the other routes works also.

Why?

It works in dev mode like "npm run dev", all works fine, but after i build it it doesnt work anymore.

Package.json scripts

"scripts": {"dev": "vite","build": "tsc && vite build","lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0","preview": "vite preview",  },

"react-router-dom": "^6.22.3",

I tried anything to fix, but it doesnt seem to work.Locally it just shows an blank page and on Cloudflare pages: "https://analyze.neiki.dev"No console error or whatever


Viewing all articles
Browse latest Browse all 16420

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>