Comments (3)
A few more things I looked into:
Express allows Regular Expressions for their routes. So even tho renderPath
is typed as a string
for AngularUniversalOptions
, if I pass in a RegEx, is will register with Express. This could mean we don't need an explicit white/blacklist. However...
I tried passing in /^\/(?!members).*/
--basically all routes except those that start with /members
--and that did indeed make it so it only rendered non member routes with SSR... but then it would result in a 404 for /members
paths.
There needs to be a fallback that will return templatePath
's contents when the renderPath
is not matched.
As a workaround for now, I put this high up in my server's main.ts
:
export async function bootstrap(): Promise<NestExpressApplication> {
const expressApp: Express = express();
expressApp.use(compression());
// this allows us to skip over SSR for members area
expressApp.get(/^\/members/, (req: Request, res: Response) => {
const path = join(__dirname, '../client/index.html');
res.sendFile(path);
});
// other code and setting up Nest...
}
It would probably work as a catchall if I registered it last, too with app.get('*', ...)
if I combined it with the RegEx renderPath
I mentioned above.
It seems like this is something that could be built into this module, maybe?
from ng-universal.
It'd be nice to have selective SSR indeed. Is it something that's planned? At the moment, I have this in my app, but I implemented it myself with React, but I'm considering Angular/Nest for another app.
from ng-universal.
We don't plan to add more features to this feature as it is supposed to be a tiny wrapper on top of @nguniversal/express-engine
. If anyone needs more functionalities, we recommend forking this package and bringing it to the project's codebase.
from ng-universal.
Related Issues (20)
- Add support for Angular 16 HOT 1
- Missing domino dependency HOT 1
- Vulnerable reason to stay here with ^0.13.1 and not ^0.14.0 HOT 1
- errorHandler does not includes the request to be able to respond something.
- Prerender with standalone application don't work HOT 1
- Nestjs ng-universal package dependency errors HOT 6
- Support in Angular 17 HOT 6
- @nestjs/ng-universal not working with Angular 13 - Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 4
- Angular 13 + ng add @nestjs/ng-universal --force (Package installed failed) HOT 2
- Can't resolve 'class-transformer/storage' HOT 2
- `npm run dev:ssr` fails to run on MacOS HOT 2
- TypeError: Class constructor Type cannot be invoked without 'new' - nest runtime error when using angular library + mikro orm HOT 7
- Please make cache methods asynchronous HOT 1
- That package not work HOT 1
- minimal app with "Error: Module parse failed" HOT 2
- Would really love to use this library with latest major nestjs version (v9) HOT 1
- [FR] Add community maintainers to this package HOT 3
- Collection "@nestjs/ng-universal" cannot be resolved HOT 1
- Angular 15 ng add dependency issue 'Packages installation failed' HOT 6
- Can't start or build server application HOT 1
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 ng-universal.