簡體   English   中英

Blazor Azure Static Web App not executing Javascript

[英]Blazor Azure Static Web App not executing Javascript

我在我的 Blazor 應用程序中使用了一點 Javascript 來做一些輕松的工作。 在我的本地計算機上一切正常。 當我發布到我的 Azure Static Web 應用程序時,Z9E13B69D1D154377 不執行。 這是錯誤消息。

拒絕執行來自“https://fullUrl/js.download”的腳本,因為它的 MIME 類型(“application/octet-stream”)不可執行,並且啟用了嚴格的 MIME 類型檢查。

這是我的 yaml 文件。

trigger:
  - main

pool:
  vmImage: ubuntu-latest
  # vmImage: windows-latest

steps:
  - checkout: self
    submodules: true

  - task: DotNetCoreCLI@2
    inputs:
      command: 'publish'
      publishWebProjects: true

  - task: AzureStaticWebApp@0
    inputs:
      app_location: '/'
      api_location: ''
      output_location: 'wwwroot'
      azure_static_web_apps_api_token: $(deployment_token)

我把它放在我的 staticwebapp.config.json 文件中。

"mimeTypes": {
    ".json": "text/json",
    ".js": "application/octet-stream"
  }

有誰知道如何讓它工作? 謝謝!

我終於讓所有這些工作了。 我將 myfile.js.download 重命名為 myfile.js。 然后我將另一個 js 文件更改為 js.js。 無論如何,這似乎是需要的改變。

這是更新的 yaml 文件。

trigger:
- master

pool:
  vmImage: ubuntu-latest
  # vmImage: windows-latest

steps:

- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    command: 'build'
    arguments: '--configuration Release'
    projects: 'YourProjectName.csproj'

- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: 'publish'
    publishWebProjects: true
    arguments: '--configuration Release'
    zipAfterPublish: false

- task: AzureStaticWebApp@0
  inputs:
    skip_app_build: true
    app_location: '/bin/Release/net5.0/publish/wwwroot'
    output_location: ''
    azure_static_web_apps_api_token: 'YOURDEPLOYMENTTOKEN'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM