git rm -r --cached .idea
.idea/
без звёздочки. Пример.const consola = require('consola')
const { Nuxt, Builder } = require('nuxt')
const app = require('./app')
// Import and Set Nuxt.js options
const config = require('../nuxt.config.js')
config.dev = process.env.NODE_ENV !== 'production'
async function start () {
// Init Nuxt.js
const nuxt = new Nuxt(config)
const { host, port } = nuxt.options.server
await nuxt.ready()
// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
await builder.build()
}
// Give nuxt middleware to express
app.use(nuxt.render)
// Listen the server
app.listen(port, host, () => {
consola.ready({
message: `Server listening on http://${host}:${port}`,
badge: true
})
})
}
start()
const express = require('express')
const app = express()
module.exports = app
serverMiddleware: {
'/api': '~/api'
},
const express = require('express')
// Create express instance
const app = express()
app.get('/', (req, res) => res.status(200).json([{name: "Robert"}, {name: "John"}]))
// Export express app
module.exports = app
// Start standalone server if directly running
if (require.main === module) {
const port = process.env.PORT || 3001
app.listen(port, () => {
console.log(`API server listening on port ${port}`)
})
}
<template lang="pug">
div
p(v-for="user in users") {{ user.name }}
</template>
<script>
export default {
async asyncData({ $axios }) {
const users = await $axios.$get('/api/')
return {
users,
}
},
}
</script>