I'm trying to add Node.js & Hapi to an existing Firebase web app that is basically a bunch of Vue components where all my app logic currently is. I added the firebase admin sdk https://firebase.google.com/docs/admin/setup.
I try to test it out by trying to serve a Vue component at http://localhost:3000/hello but get an error
{"statusCode":404,"error":"Not Found"}
Failed to load resource: the server responded with a status of 404 (Not Found)
I don't have any prior experience with Node or backend stuff in general. Not sure I'm going about this the right way. Any help with setting this up would be appreciated.
Here is my server.js
file
'use strict';
const admin = require("firebase-admin");
const serviceAccount = require("./src/firebase/serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://https://snapshelf-aa1b5.firebaseio.com/"
});
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({ port: 3000, host: 'localhost' });
server.start((err) => {
if (err) {
throw err;
}
console.log(`Server running at: ${server.info.uri}`);
});
server.register(require('inert'), (err) => {
if (err) {
throw err;
}
server.route({
method: 'GET',
path: '/hello',
handler: function (request, reply) {
reply.file('./src/components/Home/NewItems.vue');
}
});
});
via maxwellgover
No comments:
Post a Comment