在archlinux上提供静态文件时出错<cannot get =“”>

时间:2018-07-27 08:25:32

标签: express arch

我在项目中使用express“ ^ 4.16.3”,我在项目的根目录中有一个目录www,但始终收到错误Cannot GET /。 该问题仅出现在archlinux上,但是在Windows上却可以正常工作

/server/server.js

"use strict";
var express = require("express");
var path = require("path");
var app = express();

// prepare server routing
app.use("/", express.static(path.resolve(__dirname + "/../www"))); // redirect static calls
app.set("port", process.env.PORT || 3000); // main port

// cookie-based session
var cookieSession = require("cookie-session");
app.use(
  cookieSession({
    name: "forgesession",
    keys: ["forgesecurekey"],
    secure: process.env.NODE_ENV == "production",
    maxAge: 14 * 24 * 60 * 60 * 1000 // 14 days, same as refresh token
  })
);

// prepare our API endpoint routing
loadRoute("./oauthtoken");
// viewmodels sample
loadRoute("./oss");
loadRoute("./modelderivative");
// view hub models sample
loadRoute("./datamanagement");
loadRoute("./user");

function loadRoute(path) {
  try {
    require.resolve(path);
    var m = require(path);
    app.use("/", m);
  } catch (e) {}
}

module.exports = app;

我要提供的文件

  

/www/index.html

0 个答案:

没有答案