Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Is it possible to forward a web request to from ASP.Net Core to NodeServices ... #1209

Closed
mcquiggd opened this issue Aug 18, 2017 · 2 comments

Comments

@mcquiggd
Copy link

... that would enable the use of Node packages that are web request aware... e.g. interrogate the browser request for accept-language headers?

I did find this in HttpNodeInstanceEntryPoint.ts:

const server = http.createServer((req, res) => {

Which indicates that NodeServices might be able to be web aware...?

@mcquiggd mcquiggd changed the title Is it possible to forward a web request to NodeServices ... Is it possible to forward a web request to from ASP.Net Core to NodeServices ... Aug 18, 2017
@rosieks
Copy link
Contributor

rosieks commented Aug 18, 2017

It would be nice if NodeServices allow to use any express-middleware. I'm not sure if this is even possible but then it would be easier to create JavaScript applications with ASP.NET

@SteveSandersonMS
Copy link
Member

SteveSandersonMS commented Aug 21, 2017

If you're doing server-side prerendering, you can use asp-prerender-data to pass through arbitrary info from the incoming request. Likewise if you're using nodeServices.InvokeAsync(...) directly then you can pass arbitrary info. As such it's possible to pass through whatever incoming data you want into your JS code.

As for automatically passing through everything from the incoming request, we don't do that by default because it would be harmful for performance (incoming requests can be arbitrarily large, and we'd be serialising it and transferring it across processes). So it's up to you to pass through the info you need.

enable the use of Node packages that are web request aware

I'm not certain what this means exactly, as I haven't heard the term "web request aware" used elsewhere (and searching for it doesn't bring anything up). I'm guessing you mean something like connect middleware and the request/response APIs it uses. If so, it would be possible to wire up your own adapter logic manually if you want but again it's not something we have in by default, because there hasn't been demand for this nor is it clear how performant any really general-purpose solution would end up being. Sorry!

It would be nice if NodeServices allow to use any express-middleware. I'm not sure if this is even possible but then it would be easier to create JavaScript applications with ASP.NET

I did consider doing that right at the very start of the NodeServices project but I couldn't think of sufficiently compelling use cases. Also there are the perf implications I mentioned before. If you have examples of valuable things that you think a lot of developers would want to do and can't be easily achieved any other way, please let us know!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants