netlify / angular-runtime

The Angular Runtime allows Angular to run on Netlify with zero configuration
https://docs.netlify.com/integrations/frameworks/angular/
MIT License
19 stars 10 forks source link

Accessing Request and Context during Server-Side Rendering doesn't work #95

Closed advdv closed 8 months ago

advdv commented 11 months ago

Describe the bug The section of the README.md that is titled "Accessing Request and Context during Server-Side Rendering" doesn't work.

To Reproduce Default angular project following the blog post: https://www.netlify.com/blog/deploy-your-angular-v17-apps-to-netlify/

If anyone is still maintaining this repository I can provide a more elaborate project to reproduce

Expected behavior It should allow me to log the geo.city and request url. Instead the @Inject doesn't provide any value. I suspect this is because the code here: https://github.com/netlify/angular-runtime/blob/main/src/helpers/setUpEdgeFunction.js#L109 calls the render function with "platformProvider:" but I think it should be "provider:".

Versions

        "@angular/animations": "^17.0.0",
        "@angular/common": "^17.0.0",
        "@angular/compiler": "^17.0.0",
        "@angular/core": "^17.0.0",
        "@angular/forms": "^17.0.0",
        "@angular/platform-browser": "^17.0.0",
        "@angular/platform-browser-dynamic": "^17.0.0",
        "@angular/platform-server": "^17.0.0",
        "@angular/router": "^17.0.0",
        "@angular/ssr": "^17.0.7",
        "@netlify/angular-runtime": "^2.0.4",
        "@netlify/edge-functions": "^2.2.0",

If you're using the CLI to build

If you're using file-based installation

[build]
  command = "npm run build"
  functions = "netlify/functions"
  publish = "dist/angular/browser"

[[plugins]]
  package="@netlify/angular-runtime"  
Skn0tt commented 9 months ago

Hey! Sorry for not replying earlier, this got lost in a bunch of other work.

It's interesting that this broke, apparently, because we're using it in the Demo app, and it definitely used to work when I last built that based on the Angular v17 prerelease:

https://github.com/netlify/angular-runtime/blob/e9435a01feb02270a3e1ee2e5c960779988d6669/demo/src/app/dashboard/dashboard.component.ts#L19-L20

It's also interesting you mention that the provider key should be used - we ran this plugin past the Angular team before releasing, and they didn't mention anything regarding that. So definitely a peculiar issue! I'll dig into what's happening.

Skn0tt commented 9 months ago

I've redeployed the demo site for testing purposes, and i'm seeing the log line that is populated by @Inject('netlify.request') and @Inject('netlify.context') work correctly:

Screenshot 2024-02-02 at 11 52 04

Are you observing this in production or in local development? If you could provide a reproduction repository + some detailed steps on how to reproduce, that would be super helpful in finding the root cause.

Skn0tt commented 8 months ago

I'll go ahead and close this issue, since I wasn't able to reproduce it. If anybody else encounters this and has a reproduction case, please comment and i'll reopen!

quedicesebas commented 5 months ago

@Skn0tt, demo app is using angular17-next.0, did you tried with stable releeased version or even the 18 version? I can't get it work on dev, always getting undefined.