It seems to me like the build is not hitting my API. My API is currently only local and Iโm curious if that is what is causing this issue?
When npm run generate is ran on my local frontend directory, it successfully generates the static site and dist directory that I am hoping to host through netlify.
Hiya, welcome to the forum. When I search for that error, it seems like something many other folks run into when generating their Nuxt.js sites. Have you asked here? https://spectrum.chat/nuxt
Or maybe worth taking a look here (or similar issues):
Once you get that figured out, weโd be more than happy to help you with deploying to Netlify!
Ah, I misunderstood! Could you please drop a full deploy log here so we can check out what happens before and after the error? The API not being deployed could definitely be a possible source of problems, but we need a bit more information.
Thanks for sending that over. Based on the line that reads Entrypoint app = server.js, it looks like this app is trying to build a server when you run npm run generate and that wonโt work on Netlify since we only deploy static sites:
It looks like Nuxt has some docs on โgotchasโ when deploying to Netlify that may be helpful:
But the TL;DR is that frontend code that relies on server-side code will break because the server will never get set up. If itโs possible for you to make this a static site, weโd be happy to help you get it up and running
Hi, Iโm getting the same error and @jenโs reply doesnโt really add up for me since we are just running nuxt generate which is the command for generating the static files. I donโt know what that entrypoint app = server.js means but I believe it is completely standard behavior for nuxt generate.
My problem is related to the fact that I call a Netlify Function during build to generate my siteโs routes dynamically.
In nuxt.config.js I have:
generate: {
routes: dynamicRoutes
}
dynamicRoutes is defined at the top as:
import api from "./utils/api"
let dynamicRoutes = () => {
return api.readAll().then((res) => {
return res.data.map((list) => {
return {
route: '/lists/' + list.data.creator,
payload: list.data
}
})
})
}
Iโve tried all flavors of tweaking such as using fetch, using the get directly in nuxt.config.js, etc etc.
I think the problem may be that functions are deployed after the build so they arenโt accessible during build time. Could this make sense? Doesnโt really seem practical though, that means we canโt leverage the functions for fetching data to use for pre-rendering? Doesnโt seem very static site friendly if so.
The functions are deployed only at build time, so you have to both:
call previously deployed versions of the function
use a full URL - GET /.netlify/functions/lists-read-all is notโฆa valid URL - there is no sense during a build of โyou are connected to (any) URLโ, so you have to specify full network paths
Is anyone getting this to work? Iโm stumped to how no one else is having this issue when trying to deploy a nuxt app to netlify. How is there 0 documentation on this as well? Just seems crazy, Iโd think everyone trying to do a deploy would be having this issue. How does nuxt NOT use a server to generate itโs static files?
I think this has something to do with axios and either proxy or baseURL. Iโve tried a few things like turning the proxy on and off and setting a baseURL. If I give it a proxy then it gives me the ECONNREFUSED. If I try the baseURL itโs giving me a 404. NPMโs Axios doesnโt give any other details including probably the most important bit which would be the dang LOCATION of the request that is return the 404. Iโm going to remove the npm axios and reference it locally. Pretty annoying.
Was able to change the axios stuff so that I could see where the 404โs were coming from. It does look like the deploy process is trying to run some async request for whatever reason. If I give it the baseURL of the API website it still has the url/api/route when it should be just url/route. I then gave it the baseURL of / and itโs back to asking for requests from the netlify instance. I setup a _redirects file that is in my root that has
No dice. I think I give up for now. I need to rethink how all this is working because I clearly donโt understand why everyone isnโt yelling about it. Seems so easy according to the documentation, but it just isnโt happening for me.
Sorry I havenโt replied but I was able to solve my problem. I ended up having to host my api online and use that as my baseURL. My guess is it has to do with how Netlify containerizes everything and thus localhost gets funky - they are trying to access their own localhost, not what I have on my computer.
I ended up using https://ngrok.com/ to quickly host my api online, generate the pages on deployment, then drop the ngrok server. Took about 3 minutes to setup and get going.