-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Provide full request object to renderer #802
Comments
Thanks @Jefftopia. This isn't currently officially supported. As a workaround, you can define a custom renderer and server entry point. I put together a repo below that shows the changes needed in a commit. https://github.com/brandonroberts/analog-server-request It's not supported in dev mode unless you patch this file for the Vite dev server to pass the request/response the same way to the renderer. |
Thank you @brandonroberts. If I were to create a PR to pass the full object, what are some test cases you would want covered? |
I think it would be enough to add a page to the We don't have any InjectionTokens defined for those either, so those could be defined in the |
Thanks. I agree that it is not ideal to have these in client code, particularly the response. Two observations:
|
You can't scope it to the server only without using the |
@brandonroberts Working on a PR now, but it looks like the event passed to
Edit: disregard, found them in the h3 docs. |
PR adds full req and res object from h3 to the analog event handler for app rendering closes analogjs#802
This is included in the |
To provide cookies to your Angular app, it is sometimes necessary to provide it to your Angular from the server entrypoint prior to the Angular app taking over. Cookies, for example, are sometimes omitted due to Angular's xhr2's
strictCookies
setting.I have observed this both in my local analogjs app and pure Angular apps with ssr and express. To avoid this in an express-angular project, I simply provide the REQUEST to my app using the nguniversal token:
Analog does not yet provide a way to do this. The request object handled by a load hook, for example, which is really just a route resolver, is already sanitized by the framework; it is not a raw request and hence, in my case, lacked cookies.
I noticed that modifying the lines highlighted below gave me the full request with the cookies I needed:
https://github.com/analogjs/analog/blob/main/packages/vite-plugin-nitro/src/lib/runtime/renderer.js#L14-L15
analog/packages/vite-plugin-nitro/src/lib/plugins/dev-server-plugin.ts
Line 46 in c812260
I am looking for either advice on how to make a backwards compatible PR that will work with different deployments, or from an existing contributor to take point on a solution. This is unfortunately a blocker for me :-(
The text was updated successfully, but these errors were encountered: