ios Apple应用程序站点关联与Angular 路由冲突

4nkexdtk  于 6个月前  发布在  iOS
关注(0)|答案(2)|浏览(92)

有人能解释一下如何设置iOS应用程序链接来为angular工作吗?基本上,我想在邮件中发送一个链接给用户,然后打开应用程序,如果它被安装。
我在src/.well-known文件夹中添加了一个名为“apple-app-site-association”的文件,没有扩展名。
当在本地运行时,它正确地下载文件,当我去localhost:4200/.well-known/apple-app-site-association
我还在angular.json中将“src/.well-known”添加到资产中。
Web应用程序被部署到Azure静态Web应用程序,当我访问网站https://APPNAME.com/./well-known/apple-app-site-association时,它不工作。
我也检查了苹果自己的工具。https://app-site-association.cdn-apple.com/a/v1/PAGE.com
从阅读所有相关的问题,似乎Angular 看到/apple-app-site-association作为一个路由,而不是一个.json文件,我需要添加一个MIME类型到这个?
我如何让浏览器理解这是一个文件而不是一个路由?我必须在angular中的某个地方更改它,或者我必须在azure静态web应用程序中做些什么?

brgchamk

brgchamk1#

Azure Static Web Apps的路由配置应使用此DOC添加到主path中的staticwebapp.json。

  • 下面的示例代码提供了在Azure Static Web Apps中配置路由的示例。
  • 代码引用来自git
    about.component.ts:
import {Component, OnInit, ViewEncapsulation} from '@angular/core';
import {
  concat,
  fromEvent,
  interval,
  noop,
  observable,
  Observable,
  of,
  timer,
  merge,
  Subject,
  BehaviorSubject,
  AsyncSubject,
  ReplaySubject, from
} from 'rxjs';
import {delayWhen, filter, map, take, timeout} from 'rxjs/operators';

@Component({
    selector: 'about',
    templateUrl: './about.component.html',
    styleUrls: ['./about.component.css']
})
export class AboutComponent implements OnInit {

    ngOnInit() {

    }

  run() {

  }

}

字符串

about.component.html:

<div class="not-found">

    <h2>Angular Router In Depth</h2>

    <img class="course-image mat-elevation-z10"
         src="https://angular-university.s3-us-west-1.amazonaws.com/course-images/angular-router-course.jpg">

    <h1>About this course</h1>
    <p>Build large-scale Single Page Applications with the powerful Angular Router</p>

</div>

本地:


的数据

staticwebapp.config.json:

{
  "trailingSlash": "auto",
  "routes": [
    {
      "route": "/login",
      "rewrite": "/login.html"
    },
    {
      "route": "/courses",
      "rewrite": "/courses.html",
      "allowedRoles": ["authenticated"]
    },
    {
      "route": "/logout",
      "redirect": "/.auth/logout"
    }
  ],
  "navigationFallback": {
    "rewrite": "index.html"
  },
  "responseOverrides": {
    "401": {
      "rewrite": "/login.html"
    }
  }
}

Git Action中的部署状态:

Azure:



mu0hgdu0

mu0hgdu02#

多亏了Sampath,我找到了解决方案。
如果还有人想知道Azure静态Web应用程序的答案,这里是:
受此post的启发,我将apple-app-site-association.json与扩展名一起添加到路径中,因此它看起来像这样:./well-known/apple-app-site-association.json
然后,我在angular项目的根文件夹中创建了一个文件staticwebapp.json.json,其中包含:

{
    "trailingSlash": "auto",
    "routes": [
      {
        "route": "/.well-known/apple-app-site-association",
        "rewrite": "/.well-known/apple-app-site-association.json"
      }
    ],
    "mimeTypes": {
      ".json": "application/json"
    }
  }

字符串
更新angular.json以将配置文件添加到assets数组。

"assets": [
            {
              "glob": "./staticwebapp.config.json",
              "input": "./",
              "output": "/"
            },
            "src/favicon.ico",
            "src/.well-known",
            "src/assets",
            "src/routes.json"
          ],

相关问题