Служба приложения Azure Deploy не развертывает веб-приложение - PullRequest
0 голосов
/ 26 октября 2018

Я новичок в React

Я создал службу приложения узла в портале Azure с помощью веб-приложения Node JS Empty web App Starter.

Когда я захожу по URL-адресу, я вижу

Hello, world!

Что я отмечу в содержимом server.js

var http = require('http');

http.createServer(function (req, res) {

    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end('Hello, world!');

}).listen(process.env.PORT || 8080);

Я вижу, что web.config ссылается на server.js

<configuration>
    <system.webServer>

  <handlers>
            <!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
            <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
        </handlers>

        <rewrite>
            <rules>
                <!-- Don't interfere with requests for logs -->
                <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$" />
                </rule>

                <!-- Don't interfere with requests for node-inspector debugging -->
                <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">                    
                    <match url="^server.js\/debug[\/]?" />
                </rule>

                <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
                <rule name="StaticContent">
                    <action type="Rewrite" url="public{REQUEST_URI}" />
                </rule>

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

    </system.webServer>
</configuration>

КогдаЯ размещаю на сайте файлы статического реагирующего веб-сайта, я вижу, что файлы есть, но сам веб-сайт не изменяется, когда я перехожу по URL.

Я думаю, что мне нужно, чтобы веб-сайт запустилсяsrc \ app.js вместо server.js

Как мне это сделать?

Я попытался заменить server.js на ./src/App.js, но затем App.js просто отображаеткак текст.

1 Ответ

0 голосов
/ 27 октября 2018

В этом Burke Holland показано, как настроить конвейер (около дна), а также ссылки на этой статье Тони Патрина , в которой показано, как настроить 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>
...