Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

javascript - Deploy Nuxt sitemap with Firebase

I have a sitemap created with nuxt and firebase but when I deploy the site to firebase the sitemap throws and error since I am referencing my fireInit file but my nuxt.config.file has been moved to my firebase functions folder so I can deploy it. When I try to add the fireInit file in my firebase functions folder I then get an error because I am importing outside a module. Also when I take out my dynamic routes by commenting out my async routes function the site map doesn't show my custom domain url. It shows the https://us-central1-PROJECT_NAME.cloudfunctions.net.

File Structure

functions/
- nuxt.config (prod)
- index.js

 public/
- _nuxt/ (client)

 src/
 - nuxt.config (dev)

 firebase.json

Nuxt Config

module.exports = {

     modules: ['@nuxtjs/sitemap'],

    sitemap: {
        hostname: process.env.BASE_URL,
        exclude: ['/listings/create', '/listings/edit', '/profile/**'],
        async routes() {
            const { db } = require('./plugins/fireInit');
            const snapshots = await db.collection('listings').get();
            return snapshots.docs.map((doc) => `/listings/${doc.id}`);
        },
    },
}

./plugins/fireInit

import firebase from 'firebase/app';
import 'firebase/firestore';

const firebaseConfig = {
    apiKey: 'KEY',
    authDomain: 'KEY',
    projectId: 'KEY',
    appId: 'KEY',
    measurementId: 'KEY',
};

// init firebase
!firebase.apps.length ? firebase.initializeApp(firebaseConfig) : '';

// init services
export const db = firebase.firestore();
question from:https://stackoverflow.com/questions/65834239/deploy-nuxt-sitemap-with-firebase

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...