In Vite, you can add the base URL to the 404.html file by including the following code at the top of the file:
<script>
const baseUrl = import.meta.env.BASE_URL;
const url = new URL(window.location.href);
url.pathname = baseUrl + '/404.html';
window.location = url.href;
</script>
This code gets the current base URL from the Vite environment variable import.meta.env.BASE_URL
, then modifies the current URL and redirects the user to the 404 page with the updated base URL.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-23 10:09:29 +0000
Seen: 8 times
Last updated: May 23 '23
How can set the Project Title in the Doxygen Configuration File?
How can I prevent freezing when using Task.Wait in C#?
What is the process to italicize certain keywords in visual studio code?
Where should the window.mainloop() function be located for optimum Best Practices in TKinter?
How can I redirect all subdomains to the www folder using htaccess?
What is the keyboard shortcut for choosing a word and expanding the selection in VS Code?
Can you reword the phrase "VS code image viewer"?
How can I install OmniSharp for Visual Studio Code without an internet connection?