0

I'm using a little bit of Javascript in my Blazor app to do some light work. Everything works fine on my local computer. When I publish to my Azure Static Web App, the Javascript does not execute. Here is the error message.

Refused to execute script from 'https://fullUrl/js.download' because its MIME type ('application/octet-stream') is not executable, and strict MIME type checking is enabled.

Here is my yaml file.

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)

I placed this in my staticwebapp.config.json file.

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

Does anyone know how to get this to work? Thanks!

1 Answer 1

0

I finally got all of this to work. I renamed myfile.js.download to just myfile.js. I then changed another js file to js.js. Anyway, that seemed to be the change that was needed.

Here is the updated yaml file.

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'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.