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.