Comments (13)
Hello everyone,
I've found a simple workaround.
Please try this.
Thank you.
import { Context, HttpRequest } from '@azure/functions';
import { AzureHttpAdapter } from '@nestjs/azure-func-http';
import { createApp } from '../src/main.azure';
function createPsuedoApp(createApp: () => Promise<any>): () => Promise<any> {
return async (): Promise<any> => {
const app = await createApp();
const psuedoApp = {
getHttpAdapter: () => {
return {
getInstance: () => {
return (req: any, res: any) => {
const done = req.context.done;
req.context.done = (err?: string | Error, result?: any) => {
res.writeHead();
done(err, result);
};
app.getHttpAdapter().getInstance()(req, res);
};
},
};
},
};
return psuedoApp;
};
}
export default function(context: Context, req: HttpRequest): void {
AzureHttpAdapter.handle(createPsuedoApp(createApp), context, req);
}
from azure-func-http.
Hello everyone,
I have the same problem, will it be resolved?
from azure-func-http.
Ive just hit this exact same issue. Has there been any movement on this.? Only way i can currently work arouns it is remove my app.enableCors() ( as this conflicts with the adapter ) and override the HttpAdapters context
from azure-func-http.
Would be nice to have a pull request to fix it within azure-func-http.
from azure-func-http.
Please provide a minimum reproduction repository.
from azure-func-http.
Repository: https://github.com/joain946/nestjs-azure
from azure-func-http.
Any update on this @kamilmysliwiec? Do you need any additional input from me?
from azure-func-http.
I am having the exact same issue, none of the nestjs headers are being sent to the azure function only stock azure response headers. Ran the code from git and npm and having same issue.
Seems like the writeHead bound function is never getting called, breakpoint not getting hit in bound function.
this.writeHead = this.writeHead.bind(this, context);
Info: azure functions v3
from azure-func-http.
Interesting Note
When using AzureHttpRouter
const app = await NestFactory.create(AppModule, new AzureHttpRouter());
The some headers seem to be sent , most notably 'content-type'
from azure-func-http.
Hello everyone
@nlaurie @gristoi Did you find a workaround ?
@kamilmysliwiec How can we help debugging it?
We are stuck with the exact same issue.
Thank you
Felix
from azure-func-http.
We solved thia on host.json file..
{ "version": "2.0", "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[2.*, 3.0.0)" }, "functionTimeout": "01:00:00", "extensions": { "http": { "routePrefix": "api", "customHeaders": { "Content-Type": "application/json" } } } }
All we needed is json response header..
We are using microsoft docker's img to emulate in local environment.
from azure-func-http.
Hello everyone,
I've found a simple workaround. Please try this.
Thank you.
import { Context, HttpRequest } from '@azure/functions'; import { AzureHttpAdapter } from '@nestjs/azure-func-http'; import { createApp } from '../src/main.azure'; function createPsuedoApp(createApp: () => Promise<any>): () => Promise<any> { return async (): Promise<any> => { const app = await createApp(); const psuedoApp = { getHttpAdapter: () => { return { getInstance: () => { return (req: any, res: any) => { const done = req.context.done; req.context.done = (err?: string | Error, result?: any) => { res.writeHead(); done(err, result); }; app.getHttpAdapter().getInstance()(req, res); }; }, }; }, }; return psuedoApp; }; } export default function(context: Context, req: HttpRequest): void { AzureHttpAdapter.handle(createPsuedoApp(createApp), context, req); }
Only quoting to appoint the file where you need to edit. Add this script on main/index.ts
.
from azure-func-http.
Somehow this script solves the header problem, but misses the 302 status, making it 200.
Any way to keep the status and have the Location header?
from azure-func-http.
Related Issues (20)
- AzureHttpRouter constructor throws an exception HOT 3
- enable server side event support HOT 2
- Cronjobs support HOT 1
- Pls update documentation that this project is abandoned / deprecated HOT 1
- Documentation lacking around using context object to build custom logger module HOT 1
- Action Required: Fix Renovate Configuration
- TRouter constructor is undefined at runtime in AzureHttpRouter HOT 7
- Dependency Dashboard
- Response Headers are Not Matching the NEST Response when publish to Azure Function HOT 1
- package fails to install HOT 1
- exclude path not working in Azure function HOT 1
- CORS does not work with azure-func-http HOT 1
- class-validator is not working
- Make nest openapi impl better with azurefx HOT 1
- swagger-ui* not loading HOT 1
- Peer dependencies allows @azure/functions v1 or v3 but not v2 HOT 5
- MonoRepo Support HOT 1
- Azure Functions v4 support HOT 4
- Project dependencies
- Could not resolve dependency with @nestjs/common 9.0.0 HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-func-http.