vite-ssg | Static site generation for Vue 3 on Vite | Plugin library
kandi X-RAY | vite-ssg Summary
kandi X-RAY | vite-ssg Summary
Static-site generation for Vue 3 on Vite. ℹ️ Vite 2 is supported from v0.2.x, Vite 1's support is discontinued.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of vite-ssg
vite-ssg Key Features
vite-ssg Examples and Code Snippets
Community Discussions
Trending Discussions on vite-ssg
QUESTION
I am developping a website with vite which seem work like it should on localhost.
I deployed on Vercel and the site was build without errors.
But I discovered a big problem when I wanted to generate my sourcemaps. In fact, when I want to visit any page directly (.../about for example) vercel sends me a "404 not found" error. But when I go to the root page and navigate to the page manually everything is working.
Second time i visit the /about page directly, it works, but because it has been cached by my browser i think ...
hosting : vercel
base url: https://dev.energie-etre-ange.fr
404 example url : https://dev.energie-etre-ange.fr/about
used plugins :
- vite-plugin-pages
- vue-router (v4)
- vite-ssg
I can give the github link if needed, but i think this is mostly a vercel problem ? I found a linked problem on stackoverflow, but with React (link)
...ANSWER
Answered 2021-Dec-07 at 11:02Answer found here : https://stackoverflow.com/a/66686684/13541914
Credit goes to shantiscrip
Solution:
This is not a problem with vite.js but due to with a missing configuration file for vercel which is added by default to the existing templates. For a single page application the html files for the routes created with react router don't exist, so something on the server needs to create rewrites to make sure every request points at '/' or index.html. In Vercel this can be done by adding a rewrite to config file in the root of the project called
vercel.json
https://vercel.com/docs/configuration
Add rewrites for all routes to the file that point to '/'
QUESTION
I'm currently developping a simple eCommerce site with ViteJS.
My Project uses :
- Vue 3
- Vite 2.4
- vite-plugin-pages, for automatic route generation (Nuxt Style)
- vite-ssg, for server side generation (SEO optimisation)
Hosting is done on free netlify account (I am open to switch to vercel or other if needed). The Data handling is done via Headless CMS GraphCMS, hosted on their servers.
Following a tutorial on Stipe integration with NextJS & GraphCMS i came across a problem. In NextJs you can natively create server-side api routes, unlike in Vite.
As ViteSSG (Server Side Generated) has the ability of pre-rendering the shipped html, and running code on server-side, I would like to understand how I could create a server route to serve an api without having to go though the hassle of creating and hosting a seperate backend only for a simple call :
POST https://localhost:3000/api/create-checkout-session
Because if i create the stripe checkout session on the client side (inside payBtn click handler), the data (price, etc ...) could be altered by the client as the handler code would be served client-side. I want this session to be generated on server side and its Id sent back to client to be then used in the checkout process. It would remove the ability to alter the data.
I can share more code if needed, and expand information if something is not clear enough. Thanks for the help !
...ANSWER
Answered 2021-Nov-30 at 10:48In NextJs you can natively create server-side api routes
Yes because it has a server component running on Node (so you need a Node server to run the Next/Nuxt site ....unless using "generate" mode)
As ViteSSG (Server Side Generated) has the ability of pre-rendering the shipped html
Yes, during build time
and running code on server-side
I don't know why you think this but I really really doubt it. vite-ssg runs only at build time. It has no server component that is either required or even available at runtime (when serving your pre-rendered pages)
Vite itself is development tool only. Again, the "server" component of Vite is there ONLY to serve resources during development. There are some plugins which allows you to streamline creation of server side routes as vite-plugin-mix or fastify-vite but both just generates a server-side code bundle for you and you need to setup the Node server to actually run the API
But you really need some server functionality - Stripe documentation is pretty clear in that regard. But you do not need a standalone server (which needs setup and runs 24/7). What you can try is called "serverless computing". Most hosting providers have something like that including Netlify - Netlify functions
I have no direct experience with it but if you google a bit you can find an examples on how to integrate it with Vite (using proxy)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install vite-ssg
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page