This commit is contained in:
2022-12-18 13:16:42 +01:00
7 changed files with 12 additions and 64 deletions

View File

@ -20,16 +20,14 @@ function App()
<BrowserRouter basename='/dog'>
<Routes>
{ user && <Route path="/" element={<Home/>} /> }
{user && (
{ (
<>
<Route path="/:qr_id" element={<Dog/>} />
<Route path="/login" element={<Login/>} />
<Route path="/reg" element={<Register/>} />
</>
)}
{/* <Route path="*" element={<Navigate to={user ? '/':'/login'} />} /> */}
<Route path="/login" element={<Login/>} />
<Route path="/reg" element={<Register/>} />
<Route path="*" element={<Navigate to={user ? '/':'/login'} />} />
</Routes>
</BrowserRouter>
</div>

View File

@ -48,7 +48,8 @@ export type UserCtxT =
export const UserCtx = createContext<UserCtxT | null>(null);
export const Axios = axios.create({
baseURL: 'http://localhost/dog/php-dog/',
// baseURL: 'http://localhost/dog/php-dog/',
baseURL: 'https://hope-fly.de/dog/php-dog/',
});
export const UserCtxProvider = ({children}:TUserContextProviderProps) => {

View File

@ -1,52 +0,0 @@
<?php
$routes =
[
];
route('/', function () {
echo "Home Page";
});
route('/login', function () {
echo "Login Page";
});
route('/about-us', function () {
echo "About Us";
});
route('/404', function () {
echo "Page not found";
});
function route(string $path, callable $callback) {
global $routes;
$routes[$path] = $callback;
}
run();
function run() {
global $routes;
$uri = $_SERVER['REQUEST_URI'];
$found = false;
foreach ($routes as $path => $callback) {
if ($path !== $uri) continue;
$found = true;
$callback();
}
if (!$found) {
$notFoundCallback = $routes['/404'];
$notFoundCallback();
}
}
?>