Skip to content
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

"ReferenceError: window is not defined" when rendering on the server #240

Open
danieldanielecki opened this issue Aug 8, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@danieldanielecki
Copy link

Looks like Agastya access window explicitly, thus when using Server-Side Rendering (SSR) (e.g. Angular Universal) it breaks with the following error ReferenceError: window is not defined. Maybe it would be a good to add in the documentation for the workaround?

Using Express.js approach, see issue#830(comment)

Using NestJS approach applyDomino does works like so:

import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { join } from 'path';
import { Module } from '@nestjs/common';

const BROWSER_DIR = join(process.cwd(), 'dist/path/to/browser');
applyDomino(global, join(BROWSER_DIR, 'index.html'));

@Module({
  imports: [
    AngularUniversalModule.forRoot({
      bundle: require('dist/path/to/server/main'), // Bundle is created dynamically during build process.
      liveReload: true,
      viewsPath: BROWSER_DIR
    })
  ]
})
export class AppModule {}
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.82. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the bug Something isn't working label Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant