How to manually generate pages in Nuxt router with a 404 page fallback for .htaccess

My way of handling this kind of issue while minimizing the API calls required are following those steps: generate a brand new Nuxt project install axios: yarn add -D axios add this to the nuxt.config.js file import axios from ‘axios’ export default { … generate: { routes: async () => { const users = await … Read more

How to have list + details pages based on API fetched content

Since your API requires some CORS configuration, here is a simple solution with the JSONplaceholder API of a index + details list collection. test.vue, pretty much the blog listing in your case <template> <div> <div v-if=”$fetchState.pending”>Fetching data…</div> <div v-else> <div v-for=”item in items” :key=”item.id”> <nuxt-link :to=”`/details/${item.id}`”> View item #{{ item.id }}</nuxt-link> </div> </div> </div> </template> … Read more

What’s the real difference between target: ‘static’ and target: ‘server’ in Nuxt 2.14 universal mode?

Update: According to the latest documentation, mode: ‘universal’ and mode: ‘spa’ were deprecated in favor of ssr: true and ssr: false. Full static works only with target: ‘static’ and ssr: true (counterpart of deprecated mode: ‘universal’). The ssr: true is a default value. The ssr: false is a counterpart of the deprecated mode: ‘spa’ and … Read more

How to install jQuery into Nuxt.js?

I do not recommend adding jQuery to a Nuxt project. But if you really want to, you can follow those steps: install it with yarn add jquery add those to your nuxt.config.js file import webpack from ‘webpack’ export default { // … build: { plugins: [ new webpack.ProvidePlugin({ $: ‘jquery’, jQuery: ‘jquery’, ‘window.jQuery’: ‘jquery’ }) … Read more

Running an Express server middleware alongside Nuxt

You need to have at least this in your nuxt.config.js file export default { ssr: true, target: ‘server’, modules: [ ‘@nuxtjs/axios’, ], serverMiddleware: [ { path: ‘/api’, handler: ‘~/server-middleware/rest.js’ }, ], } And a /server-middleware/rest.js file with const app = require(‘express’)() app.get(‘/what-is-my-name/:name’, (req, res) => { res.json({ name: req.params.name, age: 12 }) }) module.exports = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)