wouter
wouter copied to clipboard
Redirect is not loading static file
Hello, so I am trying to redirect to a static file like so
import { Redirect, Route } from "wouter-preact";
import "./app.css";
import Header from './components/header/header';
import Navbar from './components/navbar/Navbar';
import Blog from './pages/blog/blog';
import Penguin from './pages/blog/posts/penguin';
import Contact from './pages/contact/contact';
import Now from './pages/now/now';
export function App() {
return (
<>
<>
<Navbar />
<>
<Route path="/" component={Header} />
<Route component={Penguin} path="/penguin" />
<Route component={Blog} path="/blog" />
<Route component={Now} path="/now" />
<Route component={Contact} path="/contact" />
</>
</>
<Route path="/resume">
<Redirect to="KaiResume.pdf" />
</Route>
</>
);
}
For some reason the NavBar element is still loaded in despite not being a part of page and the pdf does not load. I can go to Kai_Resume.pdf
manually and it works but /resume
does not.
what <Redirect>
component do, actually is:
navigate(options.to || options.href, options)
then the path KaiResume.pdf
, no component match this path.
Hi @KaiDevrim, what you're trying to achieve is to perform a normal page navigation (e.g. navigation caused by clicking on a regular link) with the library that relies on pushState
API. So when you're calling navigate("Kai_Resume.pdf")
it is more or less equivalent to pushState("Kai_Resume.pdf")
and your browser simply interprets it as "change the url in the address bar to "Kai_Resume.pdf") which it does.