Swagger: NestJS 7 + Azure Func

Created on 12 May 2020  路  12Comments  路  Source: nestjs/swagger

Infinity load.

GET http://localhost:7071/api/swagger-ui-init.js net::ERR_ABORTED 404 (Not Found)

main.azure.ts

```
...
// SWAGGER CONFIGURATION
const options = new DocumentBuilder()
.setTitle('Test')
.setDescription('API Documentation')
.setVersion('1.0')
.addBearerAuth()
.build();

// RUN SWAGER
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
...

package.json

...
"@azure/functions": "^1.0.3",
"@nestjs/azure-func-http": "^0.5.0",
"@nestjs/swagger": "^4.5.5",
"swagger-ui-express": "^4.1.4",
...
```

needs triage

Most helpful comment

Repository for reproduction: https://github.com/felipecassiors/nestjs-swagger-azure-func

And you can try it right now in Gitpod: https://gitpod.io/#https://github.com/felipecassiors/nestjs-swagger-azure-func

Just run:

npm install
npm run azure:start

See it works with nest start
cLdOLUPefb

But not with func host start
JOJ0ZdmSow

All 12 comments

Would you like to create a PR for this issue?

@kamilmysliwiec Sure, ill update soon

Any luck on updating this? having the same issue.

@jacobdo2 , im too busy now, can you provide a minimal repository? I can do it on monday...

Is there any workaround at the moment?

Repository for reproduction: https://github.com/felipecassiors/nestjs-swagger-azure-func

And you can try it right now in Gitpod: https://gitpod.io/#https://github.com/felipecassiors/nestjs-swagger-azure-func

Just run:

npm install
npm run azure:start

See it works with nest start
cLdOLUPefb

But not with func host start
JOJ0ZdmSow

Repository for reproduction: https://github.com/felipecassiors/nestjs-swagger-azure-func

And you can try it right now in Gitpod: https://gitpod.io/#https://github.com/felipecassiors/nestjs-swagger-azure-func

Just run:

npm install
npm run azure:start

See it works with nest start
cLdOLUPefb

But not with func host start
JOJ0ZdmSow

Thanks, @kamilmysliwiec can you check this?

Any idea when this will be fixed? I saw a pull request with a solution but it hasn't been merged yet. Kinda desperate for this since I really want to use nestjs, but if it doesn't work with swagger in combination with azure functions I need to use something else

Hi,
My company is looking for this solution.
Is there any idea when this issue will be fixed? My company really needs a solution, because we use azure functions and nestjs a lot and want to have swagger working in it.

My not a solution was to keep using azure function for calls and deploy the solution for swagger's sake somewhere else.

I have this issue too. My workaround for the swagger-ui-init.js (using an nginx server) was to add the following directive:

location = /swagger/swagger-ui-init.js {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_pass http://api_upstream/swagger/swagger-ui-init.js;
        proxy_redirect off;
        proxy_read_timeout 240s;
}

By using this exact match, the request is passed directly to NestJS.
The problem was that nginx was trying to find the file which doesn't actually exist

This issue should be reported in the swagger-ui-express repository.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kalaivanan-muthusamy picture kalaivanan-muthusamy  路  4Comments

alisherks picture alisherks  路  4Comments

otroboe picture otroboe  路  3Comments

ericzon picture ericzon  路  4Comments

malbertSC picture malbertSC  路  5Comments