SORU
29 Ocak 2013, Salı


Res ifade eder.sendfile atma yasak hatası

Bu kod var:

res.sendfile( '../../temp/index.html' )

Ancak, bu hatası atar:

Error: Forbidden
at SendStream.error (/Users/Oliver/Development/Personal/Reader/node_modules/express/node_modules/send/lib/send.js:145:16)
at SendStream.pipe (/Users/Oliver/Development/Personal/Reader/node_modules/express/node_modules/send/lib/send.js:307:39)
at ServerResponse.res.sendfile (/Users/Oliver/Development/Personal/Reader/node_modules/express/lib/response.js:339:8)
at exports.boot (/Users/Oliver/Development/Personal/Reader/server/config/routes.js:18:9)
at callbacks (/Users/Oliver/Development/Personal/Reader/node_modules/express/lib/router/index.js:161:37)
at param (/Users/Oliver/Development/Personal/Reader/node_modules/express/lib/router/index.js:135:11)
at pass (/Users/Oliver/Development/Personal/Reader/node_modules/express/lib/router/index.js:142:5)
at Router._dispatch (/Users/Oliver/Development/Personal/Reader/node_modules/express/lib/router/index.js:170:5)
at Object.router (/Users/Oliver/Development/Personal/Reader/node_modules/express/lib/router/index.js:33:10)
at next (/Users/Oliver/Development/Personal/Reader/node_modules/express/node_modules/connect/lib/proto.js:199:15)

Herkes bunun sebebini söyleyebilir mi?

CEVAP
29 Ocak 2013, Salı


Göreli yol; ".. / " kötü niyetli olarak kabul edilir. çünkü inanıyorum Yerel yolu önce gidermek, res.sendfile Ara. path.resolve önceden yolu ile çözebilirsiniz.

var path = require('path');
res.sendFile(path.resolve('temp/index.html'));

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Candyrat Records

    Candyrat Rec

    10 Mayıs 2006
  • Ryan Billy

    Ryan Billy

    30 EKİM 2006
  • theavettbrothers

    theavettbrot

    9 ŞUBAT 2007