nuxt

Getting a 404 for API routes when deploying to Heroku with Nuxt

拈花ヽ惹草 提交于 2019-12-23 00:27:30
问题 I have no idea what is going on here. My app works just fine in development, but when I push to Heroku, it throws 404 errors whenever I try to access any routes with Postman (or with Axios). What am I doing wrong here? Here is my index.js: const express = require("express"); const consola = require("consola"); const { log } = console; const { Nuxt, Builder } = require("nuxt"); const app = express(); // Import and Set Nuxt.js options let config = require("../nuxt.config.js"); // Use routes app

User redirect and authentication with middleware of Nuxt

别等时光非礼了梦想. 提交于 2019-12-13 03:44:15
问题 I'm trying to redirect a user to a login page if the user is not logged in when he tries to access certain pages with the following code. // middlware/authenticated.js import firebase from 'firebase' export default function ({ store, redirect }) { let user = firebase.auth().currentUser store.state.user = user //this doesn't work if (!user) { console.log('redirect') return redirect('/login') } } However, the problem is with this code when I refresh a page I'm redirected to login page although

ExpressJS - Serve both universal Nuxt app and AngularJS SPA

…衆ロ難τιáo~ 提交于 2019-12-12 12:29:12
问题 I have a blog project with this structure: server - written in Node/Express admin - AngularJS SPA public - AngularJS SPA (for the moment) The admin and public parts have the same domain, but the admin part uses a different subdomain, which allows me to serve the app like this in Express: app.get('*', (req, res) => { var firstIndex = req.get('host').indexOf('.'); var subdomain = req.get('host').substr(0, firstIndex).toLowerCase(); if (subdomain === '') { // Public part res.sendFile(path.join(_

Nuxt.js and anchors

岁酱吖の 提交于 2019-12-11 17:18:40
问题 How to deal with anchors (within the same page) in Nuxt.js ? Problem is the URL stays always on the base localhost:3000/ I want to have anchors displayed on the URL too: localhost:3000/#anchor1 , localhost:3000/#anchor2 , localhost:3000/#anchor3 … etc. It seems <nuxt-link :to=(/#anchorid)> Inner link </nuxt-link> does not do the job. How to achieve this functionality? 来源: https://stackoverflow.com/questions/55196920/nuxt-js-and-anchors

Nuxt.js: message: 'This page could not be found' (nuxt-i18n)

谁说我不能喝 提交于 2019-12-11 16:57:30
问题 In my Nuxt.js application, I installed the nuxt-i18n according to how the documentation suggests: { modules: [ ['nuxt-i18n', { // Options }] ] } But when I run npm run dev, I get this error message: DONE Compiled successfully in -4519ms 12:53:52 OPEN http://localhost:3000 nuxt:render Rendering url / +0ms { statusCode: 404, path: '/', message: 'This page could not be found' } How to fix this? 回答1: it works fine if you set a default locale :) modules: [ ['nuxt-i18n', { locales: ['en', 'fr', 'es

Can we combine the SPA concept with dynamic nested routes in Nuxt.js?

北战南征 提交于 2019-12-11 15:58:29
问题 In my Nuxt.js application, I have to use dynamic nested routes. This means I will end up by having various HTML files generated. The problem is that I must embed my whole application within an existing website, on a specific page, to be precise. In the beginning I thought only one page will be needed, but finally I ended up by having multiple pages. How can I embed my files given these constraints? Any approach? Is it possible to combine the SPA concept with dynamic nested routes? 回答1: These

How to deploy Nuxt SSR with mod_rewrite in a sub folder?

风格不统一 提交于 2019-12-11 15:56:48
问题 Currently I'm running a Django based website. I want to replace my "/admin/" area with a Vue/Nuxt build version but keep the rest of my website for now. To serve my files I use Apache2 with mod_rewrite enabled. My Nuxt server is running on localhost:3000. In my .htaccess I wrote this line to proxy /admin/ to the Nuxt Server RewriteRule ^admin/(.*) http://localhost:3000/$1 [P] If I access www.example.com/admin/ I see the output of my Nuxt project. But all resources are not loaded because the

render function or template not defined in component: anonymous

*爱你&永不变心* 提交于 2019-12-11 07:21:35
问题 I have such a problem, after reloading the page an error occurs."render function or template not defined in component: anonymous". I think the error is due to socket.io. What does this error do not occur on the local machine, but on the production. dev версия error server.js const APP_ENV = require('./.env.js') const { Nuxt, Builder } = require('nuxt') const app = require('express')() let server = require('http').Server(app) if(APP_ENV.ssl) { const fs = require('fs') const options = { key: fs

Vuetify - How to trigger method when clear a v-text-field

廉价感情. 提交于 2019-12-10 13:35:49
问题 is there a way to call a method while clearing a text-field with Vuetify? <v-text-field class="mt-2 mb-0" clearable solo v-model="searchQuery" append-icon="search" @click:append-outer="searchCos" label="Nom de compagnies ou mots-clés"> </v-text-field> ... onClear() { doSomethingHere } Thanks Francis 回答1: You can use the @click:clear="()" so you can clear your text at the same time it will call the function. Here's the example https://codepen.io/anon/pen/ePmLOg?editors=1010 回答2: Use the clear

Nuxt Multiple assets emit to the same filename hot-update

Deadly 提交于 2019-12-08 07:26:14
问题 So I've been using Nuxt currently without Express and it was working fine. Today I have installed Nuxt again and also picked to install Express with it. Now when I do changes to the files I get this error: Whan can cause this error ? When I restart server with npm run dev it works fine again until I change a file. 回答1: Webpack 4.40.0 was released 12 hours ago. 4.40.1 was released about 15 minutes ago with this error mentioned in the release notes. See github.com/webpack/webpack/releases/tag