2017-02-02 4 views
2

Azure 웹 사이트에 node.js/express 앱을 배포 할 때 브라우저에서 "GET /"오류가 발생합니다. 동일한 응용 프로그램이 로컬 컴퓨터에서 완벽하게 실행됩니다.Azure 웹 사이트 + node.js - GET/

web.config 때문에, (나는 단지 정적 재 작성 규칙을 제거) 표준 :

<!-- All other URLs are mapped to the node.js site entry point --> 
    <rule name="DynamicContent"> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/> 
     </conditions> 
     <action type="Rewrite" url="src/server/app.js"/> 
    </rule> 
    </rules> 

코드는 src/server/ (노드 기능) 및 src/client/ (정적 컨텐츠) 폴더에 배포됩니다. FREB 당으로

는 SRC/서버/apps.js가 페치 기록했지만 결국 다음과 같은 오류가 발생합니다 : app.js 내부

ErrorCode The system cannot find the file specified.  (0x80070002) 

I가 정적 파일에 대한 다음과 같은 구성 :

app.use(express.static('./src/client/')); 

답변

1

Azure 웹 사이트는 시작 파일로 package json에 정의 된 파일이있는 폴더에서 노드를 실행합니다. 다음과 같은 사항에 대해 :

"start": "node src/server/app.js" 

사실은 그것이 src/server 폴더에서 node app.js를 실행합니다 (당신은 또한 거기에 iisnode.yml 파일을 찾을 수 있습니다). 모든 상대 경로가 엉망이 된 결과. 이를위한 한 가지 해결책은 절대 경로를 사용하는 것입니다. 예 :

app.use(express.static('D:/home/site/wwwroot/src/client/')); 

process.env.NODE_ENV 변수.

+0

다른 해결책은 시작 스크립트를 src/server /에서 wwwroot/folder로 이동하는 것입니다. 이 경우 하나의 파일 만 변경하면됩니다. –