2014-12-22 1 views
0

공용 디렉토리 내에서 http://<IP Address>:3000/image.jpg을 통해 내 정적 이미지 파일에 액세스하려고하며 내 서버에 로그인 한 경우에만 사용할 수 있습니다. 최대한 빨리 로그 아웃으로 나는Express.js 로그인시에만 사용할 수있는 공용 폴더 콘텐츠

네트워크 탭에서 찾을 수 없습니다 (404)를 GET 얻을 대신 페이지의 :

Error: Not Found 
    at module.exports (<path>/app.js:48:15) 
    at Layer.handle [as handle_request] (<path>/node_modules/express/lib/router/layer.js:82:5) 
    at trim_prefix (<path>/node_modules/express/lib/router/index.js:271:13) 
    at <path>/node_modules/express/lib/router/index.js:238:9 
    at Function.proto.process_params (<path>/node_modules/express/lib/router/index.js:313:12) 
    at <path>/node_modules/express/lib/router/index.js:229:12 
    at Function.match_layer (<path>/node_modules/express/lib/router/index.js:296:3) 
    at next (<path>/node_modules/express/lib/router/index.js:190:10) 
    at <path>/node_modules/express/lib/router/index.js:192:16 
    at Function.match_layer (<path>/node_modules/express/lib/router/index.js:296:3) 

app.js 파일 app.use(express.static(__dirname + '/public')); 있습니다.

내 모든 경로가 정상적으로 작동하고 로그 아웃 할 때 경로를 요청할 때 JSON 응답이 표시되며 공용 디렉토리 내의 파일에만 문제가 발생합니다.

는 내가 최고하지만 같은 문제에 app.use(express.static(__dirname + '/public'));를 이동하려고 forever start -c nodemon bin/www

으로 서버에 내 스크립트를 실행하고 있습니다.

내 서버에 로그인 할 때 공용 폴더에만 액세스 할 수있는 이유는 누구입니까?

+0

미들웨어 및 경로의 순서는 순서대로 실행되기 때문에 무엇입니까? 요청이 정적이되기 전에 경로를 조회하고 응답 (사용자의 경우 404)을 반환하면 파일을 제공하지 않습니다. –

+0

첫 번째 'app.use (express.static (__ dirname +'/ public '));' 그리고 모든 길. – user3599444

+0

static 앞에 정의 된 다른 미들웨어가 있습니다 –

답변

0

내 프로젝트 폴더의 소유자 및 그룹에 문제가있었습니다. 나는 this article (첫 번째 익스프레스 앱 파트)에서 단계를 밟았으며 모든 것이 이제는 잘 작동한다.