标签: azure-static-website-routing

使用 React Router 进行 Azure 静态应用程序路由配置

我正在尝试在天蓝色上配置静态应用程序,但很难正确路由。当我导航到/lti/login/应用程序内时,它工作正常。但如果我刷新它会抛出 404,这告诉我我的routes.json设置不正确(也许)。我希望有人能对此有所启发。

routes.json

{
    "routes": [
      {
        "route": "/",
        "serve":"/"
  
      },
      {
        "route": "/lti/login/*",
        "serve":"/lti/login"

      }
     
    ]
  
  }
Run Code Online (Sandbox Code Playgroud)

App.js

   <Router>
      <div>
        <ul>
          <li>
            <Link to="/">Home</Link>
          </li>
          <li>
            <Link to="/lti/login/">About</Link>
          </li>
        </ul>

        <hr />

        {/* A <Switch> looks through its children <Route>s and
          renders the first one that matches the current URL. */}
        <Switch>
          <Route exact path="/">
            <Form />
          </Route>
          <Route path="/lti/login/*"> <----- If I navigate to this within the app and then refresh it throws a …
Run Code Online (Sandbox Code Playgroud)

reactjs azure-static-website-routing azure-static-web-app

14
推荐指数
3
解决办法
9923
查看次数

staticwebapp.config.json 无法与 github Azure 静态网站一起使用?

我创建了一个具有以下文件结构的简单站点:

/index.html /down.html /.github/workflows/azure-static-web-apps-xxxx.yml /staticwebapp.config.json

这样就可以部署了,我可以看到我的索引和下页,如果我修改其中任何一个,它就会神奇地出现在网站上。

问题是它忽略 staticwebapp.config.json

我不知道该把它放在哪里,但我猜测根源。它不起作用。据推测它没有被读取或处理。

yaml 文件如下所示。我不知道它从哪里来,也不知道我是否需要它,因为该网站将是纯 HTML(非库、js 或框架):

名称:Azure 静态 Web 应用 CI/CD

在:
  推:
    分支机构:
      - 主要的
  拉请求:
    类型:[打开、同步、重新打开、关闭]
    分支机构:
      - 主要的

工作:
  构建和部署作业:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != '关闭')
    运行:ubuntu-latest
    名称:构建和部署作业
    脚步:
      - 使用:actions/checkout@v2
        和:
          子模块:true
      - 名称:构建和部署
        id: 构建部署
        使用:Azure/static-web-apps-deploy@v0.0.1-preview
        和:
          azure_static_web_apps_api_token:${{secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_xxx }}
          repo_token: ${{ Secrets.GITHUB_TOKEN }} # 用于Github集成(即PR评论)
          动作:“上传”
          ###### 存储库/构建配置 - 可以配置这些值以满足您的应用程序要求。######
          # 有关静态 Web 应用程序工作流配置的更多信息,请访问:https://aka.ms/swaworkflowconfig
          app_location: "/" # 应用源代码路径
          api_location: "api" # Api源代码路径 …

azure-static-website-routing azure-static-web-app

6
推荐指数
1
解决办法
1万
查看次数