[英]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
文件夾中有一個scripts
和templates
文件夾。
但是,當我轉到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.