Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web.config doesn't have mime type for .json from nitro preset iis-node #2999

Open
js-writer opened this issue Jan 14, 2025 · 2 comments
Open

Comments

@js-writer
Copy link

js-writer commented Jan 14, 2025

Environment

Node 18.
Nuxt 3.15.1 with Nitro 2.10.

Azure Windows, iis_node web app.

Reproduction

Create simple nuxt app and deploy it to Azure Web App on Windows IIS with Node server.

Describe the bug

Nitro create web.config when build contains preset iis-node. But web.config doesn't include json mime types so server returns error 404:
image
Is there a way to add mime type for iis setting in nuxt.config.ts?

Additional context

No response

@pi0
Copy link
Member

pi0 commented Jan 14, 2025

In order to add additional config to the generated .output/web.config for a nuxt project:

export default defineNuxtConfig({
  nitro: {
    iis: {
      mergeConfig: true,
    },
  }
});

web.config (in project root)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
      <mimeMap fileExtension=".wasm" mimeType="application/wasm" />
      <mimeMap fileExtension=".json" mimeType="application/json" />
    </staticContent>
  </system.webServer>
</configuration>

Or full config to override:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
  <system.webServer>
    <webSocket enabled="false"/>
    <handlers>
      <add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^index.js/debug[/]?"/>
        </rule>
        <rule name="StaticContent">
          <action type="Rewrite" url="public{PATH_INFO}"/>
        </rule>
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
          </conditions>
          <action type="Rewrite" url="index.js"/>
        </rule>
      </rules>
    </rewrite>
    <security>
      <requestFiltering>
        <hiddenSegments>
          <remove segment="bin"/>
        </hiddenSegments>
        <requestLimits maxAllowedContentLength="4294967295"/>
      </requestFiltering>
    </security>
    <httpErrors existingResponse="PassThrough"/>
    <iisnode watchedFiles="index.js" node_env="production" debuggingEnabled="false" loggingEnabled="false"/>
    <staticContent>
      <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json"/>
      <mimeMap fileExtension=".wasm" mimeType="application/wasm"/>
      <mimeMap fileExtension=".json" mimeType="application/json"/>
    </staticContent>
  </system.webServer>
</configuration>

Can you try if this fixes issue for you?

@js-writer
Copy link
Author

Yes, this solution is working (first one also). Thank you.

@pi0 pi0 added enhancement New feature or request workaround available and removed pending triage labels Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants