server-side-rendering

React - “localStorage is not defined” error showing

送分小仙女□ 提交于 2020-03-13 07:19:09
问题 I am trying to make my website SEO friendly with meta tags. I am implementing server-side rendering in my application. After this, I am getting the following error: ReferenceError: localStorage is not defined. Please help how to resolve it. My package.json : { "main": "server.js", "scripts": { "start-dev": "NODE_ENV=development webpack -w & NODE_ENV=development node server.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC",

Gatsby server-side rendering of page with client-only routes, based on window location

冷暖自知 提交于 2020-01-25 06:49:28
问题 I am working on a Gatsby project (a language learning blog) and am having trouble with an issue that only happens in production builds due to server-side rendering. I programmatically generate a page for each blog post with the following scheme: /posts/{post-name} . Each post can also have a number of subpaths that map to open tabs in the UI. For example, /posts/important-spanish-verbs/lesson would open the lesson tab. Each page has a matchPath property of /posts/{post-name}/* , and these are

Conditional Rendering on Server Side

不打扰是莪最后的温柔 提交于 2020-01-25 00:29:24
问题 Background I am using next.js for server side rendering and react.js for client side. Goal Want to do conditional rendering on the basis of window size in server side. Like for 200px width render A component and for 400px width render B component. Problem In server side, we have no access to the window object and we have no idea about the device our client is using. So AFAIK we cant do conditional rendering on server side. Thoughts I have thought of some solutions, but don't know is it

Conditional Rendering on Server Side

好久不见. 提交于 2020-01-25 00:29:03
问题 Background I am using next.js for server side rendering and react.js for client side. Goal Want to do conditional rendering on the basis of window size in server side. Like for 200px width render A component and for 400px width render B component. Problem In server side, we have no access to the window object and we have no idea about the device our client is using. So AFAIK we cant do conditional rendering on server side. Thoughts I have thought of some solutions, but don't know is it

Nuxt: How to add content/scripts to the head dynamically on server side

大憨熊 提交于 2020-01-24 14:35:56
问题 How can I add dynamically content to the head in Nuxt on server side? I was trying to rewrite this module here which supports only static id's: https://github.com/nuxt-community/modules/blob/master/packages/google-tag-manager/index.js (My id is coming from the store (The store is fetching the id from a rest call)) This is the function which is adding the content to the head: export default function addheadcode(head, id) { const options = { id: id, layer: 'dataLayer', pageTracking: true,

Nuxt: How to add content/scripts to the head dynamically on server side

帅比萌擦擦* 提交于 2020-01-24 14:35:12
问题 How can I add dynamically content to the head in Nuxt on server side? I was trying to rewrite this module here which supports only static id's: https://github.com/nuxt-community/modules/blob/master/packages/google-tag-manager/index.js (My id is coming from the store (The store is fetching the id from a rest call)) This is the function which is adding the content to the head: export default function addheadcode(head, id) { const options = { id: id, layer: 'dataLayer', pageTracking: true,

Angular2 Server-side rendering of main app.module

拈花ヽ惹草 提交于 2020-01-17 07:08:06
问题 I'm fairly new to Angular2, so apologies if there is an obvious answer or if I'm misunderstanding the way server-side rendering works. We have an Angular2 project, initially based on Steven Sanderson's .net core template, with server-side rendering etc, but we've upgraded webpack and Angular a couple of times since. We've had to disable the server-side rendering because we're using devexpress for Angular2 (issue here), alongside a couple of other libraries that don't sit very well with server

Is server-side rendering always efficient? [closed]

為{幸葍}努か 提交于 2020-01-17 01:21:09
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I had this question in my mind for a while. So let's assume that we have a front-end server that has enough load and hit for just for sending files over the network to client. Would you still say server-side rendering would make it more performant? or it will actually

React Development and Build version not working in IE 11 and Edge - Webpack/Babel

房东的猫 提交于 2020-01-16 19:31:34
问题 Development and build version not working in IE 11 and Edge. Here are my webpack config and package json file. I have used below repo. https://github.com/kriasoft/react-starter-kit I have been trying to fix this issue using various babel packages and webpack configurations. Arrow function seems not to be working. Here's the error. webpack.config.js /** * React Starter Kit (https://www.reactstarterkit.com/) * * Copyright © 2014-present Kriasoft, LLC. All rights reserved. * * This source code

Angular 6 | Server side rendering: issue 'window not defined'

对着背影说爱祢 提交于 2020-01-14 06:26:08
问题 I have updated my application from angular version 5 to latest. Here's detail: Angular CLI: 6.2.1 Node: 8.12.0 OS: win32 x64 Angular: 6.1.6 Also I am using this: ng-toolkit-universal to achieve server side rendering. I am able to build application using command " npm run build:prod " , but facing following issue while running command: "n pm run server ": Can anyone please help or suggest some soution for the same. Thanks in advance! 回答1: Assuming you are done SSR with angular universal. Put