Using cookies in Universal Rendering using angular-cli -
i have made angular app using angular-cli , doing universal rendering in following steps given here . mentioned can't use global variables window , document in app if doing universal rendering, how can set cookies @ front end maintain user session. using jwt, doing need set cookies in browser.
i have had success using npm package ng2-cache (i using angular 4 , works fine). using local storage, have in module providers array this:
providers: [ cacheservice, {provide: cachestorageabstract, useclass: cachelocalstorage}, ... ]
another option use isplatformbrowser() shown here.
the ugliest option put code dealing cookies in try-catch statements. way work on browser , ignored on server side.
Comments
Post a Comment