1

I've just created a Nuxt3 in static mode but I don't want to push it to Netlify everytime to preview it.

Here is my nuxt.config.js (nothing changed)

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
})

Also, I don't know why but yarn generate is not working as you can see below, it says

Preview is not supported for this build

enter image description here

Opening the index.html file directly is not helping because I do have a lot of errors + my API calls are not working.

enter image description here

kissu
  • 40,416
  • 14
  • 65
  • 133

1 Answers1

3

If you want to preview your statically generated content, you will still need a light server to serve the assets + handle the API requests etc.
Even host providers like Netlify/Vercel do run a small server to serve static files.

The fastest solution is probably to use serve, you don't have to install it directly on your system (I didn't achieved to make it work myself).

You can run npx serve .output/public to have something working in no time and get a functional preview.

enter image description here

kissu
  • 40,416
  • 14
  • 65
  • 133
  • 1
    As you said a light server is needed... In my case I use `python` module with 'python3 -m http.server' command to serve static content... Another easy approach is using `Firebase Hosting` since it takes only a few seconds to deploy static content on their CDN. – dikesh May 05 '22 at 06:30
  • 1
    @dikesh yeah, this is also a common one indeed! I don't really use Python myself but it's a good point. Regarding Firebase, few seconds + changing windows is too much work tbh, I need to check the result in 3s max usually. Especially when debugging. Otherwise, Netlify can do that super quickly too. – kissu May 05 '22 at 07:25
  • I was searching for this for the while, Great to have it. One Help sir, please – ash Dec 15 '22 at 06:16
  • Please Kissu Nuxt + Graphql Authentication please – ash Dec 15 '22 at 06:53
  • 2
    Hi @ash, this is not the place to ask such things. Create a new question. – kissu Dec 15 '22 at 14:02
  • I created the Question. Why do I ask every time in a comment generally, no one answers these types of questions randomly. And it just wastes the effort and time of writing the Question. Please help @kissu https://stackoverflow.com/q/74815149/17226535 thankyou – ash Dec 15 '22 at 17:07
  • Do you know that you are one of my strengths? Thank you so much for being a very kind guy. And please grow your channel. You could create a difference. – ash Dec 15 '22 at 17:09