W
Wasp-lang2mo ago
xi

Help: path:"/" to: "pubilc/index.html"

How to route the path:"/" to the index.html file
6 Replies
kapa.ai
kapa.ai2mo ago
Hi @xi. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In Wasp, you can define a route in your main.wasp file that points to a specific page component. However, Wasp doesn't directly support routing to a static HTML file like index.html. Instead, you would create a React component that serves as the main page of your application, and then route to that component. Here's an example of how you might define a route to a main page:
route HomeRoute { path: "/", to: MainPage }
page MainPage {
component: import Main from "@ext/MainPage.js"
}
route HomeRoute { path: "/", to: MainPage }
page MainPage {
component: import Main from "@ext/MainPage.js"
}
In this example, MainPage.js would be a React component that serves as the main page of your application. You can include any HTML content you need within this component. If you're trying to serve static files, you might need to set up a custom server or use a different approach. Wasp currently doesn't provide built-in support for serving static files. For more information on routing in Wasp, you can check out the official documentation (https://wasp-lang.dev/docs/advanced/apis#using-the-api-from-the-client). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @xi, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
xi
xi2mo ago
How do I set up a custom server?
Filip
Filip2mo ago
Hi @xi, What do you want to achieve, specifically? Why would you need the route / to go to your custom file if you're using Wasp? I suggest taking a look at our official documentation on static asset handling: https://wasp-lang.dev/docs/project/static-assets#the-public-directory
Static Asset Handling | Wasp
Importing an Asset as URL
xi
xi2mo ago
Hi @sodic, I want to achieve the purpose of SEO optimization, my index, html files are already optimized static pages.When request/interface, jump directly to index.html. [Page source code] Display all the label elements of the page, which is conducive to Google crawlers to capture.
Filip
Filip2mo ago
What kind of app are you building? If your index and static files are already optimized, then perhaps a full stack app framework is not the best fit for you
xi
xi2mo ago
Thanks for your reply, I finally replaced it with next.js.
Want results from more Discord servers?
Add your server