您无权查看Azure Ionic App

时间:2017-10-31 10:22:40

标签: node.js cordova azure typescript ionic2

我的Ionic2 Node.js应用程序在本地运行,我使用GitBash将其成功推送到azure。

浏览时显示:

  

“您无权查看此目录或页面。”

我确实添加了

web.config,process.json,index.js,

"start": "node index.js" 

在package.json和'azure mobile service'插件中。

没有进展。有人可以帮忙吗?谢谢......

Simple ionic blank project

Web.Config中:

<configuration>
<system.webServer>
      <handlers>
        <add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
      </handlers>
      <rewrite>
            <rules>
                <rule name="SPA">
                    <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> 

process.json:

{
  "name": "worker",
  "script": "./index.js",
  "instances": 1,
  "merge_logs": true,
  "log_date_format": "YYYY-MM-DD HH:mm Z",
  "watch": true,
  "watch_options": {
    "followSymlinks": true,
    "usePolling": true,
    "interval": 5
  }
}

的package.json:

{
  "name": "io.cordova.myappd3d469",
  "author": "",
  "homepage": "",
  "private": true,
  "scripts": {
    "start": "node index.js",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve",
    "watch": "ionic-app-scripts watch"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.7",
    "ionic-angular": "2.0.1",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.1.0",
    "typescript": "2.0.9"
  },
  "description": "Ionic2Blank: An Ionic project",
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "-vs-binding": {
    "BeforeBuild": [ "ionic:build" ]
  }
}

index.js:

var http = require('http');

var server = http.createServer(function (request, response) {

    response.writeHead(200, { "Content-Type": "text/plain" });
    response.end("Hello World!");

});

var port = process.env.PORT || 1337;
server.listen(port);

console.log("Server running at http://localhost:%d", port);

Azure网络应用设置:

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以改为使用以下<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.webServer> <handlers> <add name="iisnode" path="index.js" verb="*" modules="iisnode" /> </handlers> <rewrite> <rules> <!-- 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 site entry point --> <rule name="DynamicContent"> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" /> <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" /> </conditions> <action type="Rewrite" url="index.js" /> </rule> </rules> </rewrite> </system.webServer> </configuration>

/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/definitions/index.js:147:13:
   imports/ui/components/Public.js: Property elements[3] of ArrayExpression expected node to be of a type
   ["null","Expression","SpreadElement"] but instead got undefined
   at validate
   (/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/definitions/index.js:147:13)
   at validator
   (/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/definitions/index.js:57:7)
   at Object.validate
   (/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/definitions/index.js:190:10)
   at validate
   (/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/index.js:505:9)
   at Object.builder
...
...