小编Geo*_*rji的帖子

Firebase 函数不使用 express.js 和 EJS 视图引擎提供静态文件

过去一个月我一直在研究这个问题,但没有找到任何有用的解决方案。我目前正在尝试使用 firebase 函数以及 express.js 和 EJS 视图引擎来托管网站。

我将讨论将静态 CSS 文件提供给 EJS 文件的问题。我已经看遍了,但似乎找不到任何有帮助的正确答案。

我有以下文件结构(在函数文件夹内):

  • 民众
  • 意见
  • 索引.js

这是我的 index.js:

const functions = require('firebase-functions');
const express = require("express");
const ejs = require("ejs");
var path = require('path');

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
//  response.send("Hello from Firebase!");
// });

var app = express();

app.set('view engine', 'ejs');

// app.use('/static', express.static('public'));
app.use(express.static(__dirname + "/public"));
app.get("/", (request, response) => {
    response.render("test");
}) …
Run Code Online (Sandbox Code Playgroud)

ejs node.js express google-cloud-functions

6
推荐指数
1
解决办法
2546
查看次数

标签 统计

ejs ×1

express ×1

google-cloud-functions ×1

node.js ×1