scottie1984 / swagger-ui-express

Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.4k stars 225 forks source link

refused to execute in browser #360

Open vipincodewave opened 9 months ago

vipincodewave commented 9 months ago

Refused to execute script from 'http://localhost:3000/swagger-ui-bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Falven commented 9 months ago

pnpm install -D swagger-ui-dist

import { copy } from 'esbuild-plugin-copy';

copy({
      assets: [
        {
          from: ['./node_modules/swagger-ui-dist/swagger-ui-bundle.js'],
          to: 'SwaggerUIBundle.js',
        },
        {
          from: ['./node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js'],
          to: 'SwaggerUIStandalonePreset.js',
        },
      ],
    }),
robertoDCJ commented 2 days ago

but where do I put this?

Falven commented 8 hours ago

but where do I put this?

Your ESBuild script.