簡體   English   中英

我的簡單Express Server不會提供靜態JS文件

[英]My simple Express Server won't serve static JS files

我的快遞(3.X)服務器看起來像:

express = require "express"
app     = express()



app.configure ->
  app.use express.static(__dirname + '/public')
  app.use app.router


console.log __dirname + '/public'
app.get "*", (req, res) ->
  res.sendfile "index.html"


app.listen 1234
console.log "Server listening on port 1234"

我正在將它用於AngularJS項目,所以如果/public文件夾中有任何內容,我希望它直接提供。 我的/public文件夾中有一個scriptstemplates文件夾。

但是,當我轉到http://localhost:1234/public/scripts/app.js ,我得到了index.html的內容

在這種情況下, /public是您的webroot。 您需要更改對http://localhost:1234/scripts/app.js引用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM