2017-02-01 83 views
2

我使用create-react-app来开发我的React应用程序。现在我想在云上发布这个包。所以我做:用azure部署create-react-app

npm run build 

它创造了一个build文件夹,我初始化的回购:

git init 

加入原点

git remote add origin https://mysiteonazure.com/app.git 

最后提交和推送的文件。所以我能够查看我的应用程序。当我想使用URL导航时出现问题,因此移动到:

http://mysiteonazure.com/login 

没有工作。

我到了下面的文章Deploying create-react-app on Microsoft Azure

所以我的构建有:

build-azure 
|_.git 
|_static 
|_asset-manifest-json 
|_favicon.ico 
|_index.html 

现在我加入web.config

build-azure 
|_.git 
|_static 
|_asset-manifest-json 
|_favicon.ico 
|_index.html 
|_web.config 

有了:

<?xml version=”1.0"?> 
<configuration> 
<system.webServer> 
<rewrite> 
<rules> 
<rule name=”React Routes” stopProcessing=”true”> 
<match url=”.*” /> 
<conditions logicalGrouping=”MatchAll”> 
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” /> 
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” /> 
<add input=”{REQUEST_URI}” pattern=”^/(api)” negate=”true” /> 
</conditions> 
<action type=”Rewrite” url=”/” /> 
</rule> 
</rules> 
</rewrite> 
</system.webServer> 
</configuration> 

但现在,当我去到主画面:http://mypage.azurewebsite.net我得到:

的页面,因为内部服务器错误有 出现无法显示。

我该如何解决这个问题?或者,我如何正确发布我的应用程序?

+0

你可以看到捻日志? –

+0

你的web.config文件是什么? –

+0

@MichalCumpl我用'web.config'更新了我的帖子。是的,我可以访问Kudu的日志,你需要什么样的信息? – FacundoGFlores

回答

3

给出的详细信息,这个问题是引号,我复制从给定的源web.config,并且它有其他报价,所以真正的web.config是:

<?xml version="1.0"?> 
<configuration> 
<system.webServer> 
<rewrite> 
<rules> 
<rule name="React Routes" stopProcessing="true"> 
<match url=".*" /> 
<conditions logicalGrouping="MatchAll"> 
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" /> 
</conditions> 
<action type="Rewrite" url="/" /> 
</rule> 
</rules> 
</rewrite> 
</system.webServer> 
</configuration>