Nuxt.js example for running Netlify functions locally in a dev environment and as a generated static site deployed to Netlify.
Heavily inspired by the official guide and this example.
Live demo can be found here.
For the requests on the client side we use the Axios Module. To proxy locally you have to set up the Proxy Module in nuxt.config.js
:
proxy: {
'/.netlify': {
target: 'http://localhost:9000',
pathRewrite: { '^/.netlify/functions': '' }
}
}
# Use nvm
$ nvm use
# Install dependencies
$ yarn
# Build lambda functions locally
$ yarn netlify-lambda build netlify-lambda-src
# Serve lambda functions locally
$ yarn netlify-lambda serve netlify-lambda-src
# Serve nuxt app with hot reload at localhost:3000
$ yarn dev
# Generate static project
$ yarn generate