ssr

How to use React.Component with renderToString method?

眉间皱痕 提交于 2019-12-12 01:25:44
问题 I tried to do the server side render using renderToString method. function handleRender(req, res) { const html = renderToString( <Counter /> ); res.send(renderFullPage(html)); } function renderFullPage(html) { return ` <!doctype html> <html> <head> <title>React Universal Example</title> </head> <body> <div id="app">${html}</div> <script src="/static/bundle.js"></script> </body> </html> ` } If the component like following it works: Counter.js const Counter = () => { function testClick(){

How to deploy Nuxt SSR with mod_rewrite in a sub folder?

风格不统一 提交于 2019-12-11 15:56:48
问题 Currently I'm running a Django based website. I want to replace my "/admin/" area with a Vue/Nuxt build version but keep the rest of my website for now. To serve my files I use Apache2 with mod_rewrite enabled. My Nuxt server is running on localhost:3000. In my .htaccess I wrote this line to proxy /admin/ to the Nuxt Server RewriteRule ^admin/(.*) http://localhost:3000/$1 [P] If I access www.example.com/admin/ I see the output of my Nuxt project. But all resources are not loaded because the

Use Express.js in an existing Nuxt.js project

落爺英雄遲暮 提交于 2019-12-11 15:06:06
问题 I have a project built with Nuxt.js and I want to use express to be able to report bugsnag errors on my asyncData method etc. How would I go to import that? I suppose is not as simple as npm install express --save. I already have an api written in PHP so I would not use that as an api or anything else. Is it overkill? Or is it a necessary evil? :D 回答1: You dont need express to handle errors in asyncData. To handle errors in asyncData/fetch on ssr you just need to hook into render

Cross sub domain cookies on azure

只愿长相守 提交于 2019-12-11 14:48:58
问题 My applications consists of 2 parts: The web API, written in .NET Core The web app, written in React and rendered using a nodejs express server I am hosting these parts on azure, each on it's own sub domain so we have: api.azurewebsites.net app.azurewebsites.net When the user logs in I set a cookie, to my understanding a cookie can be used accross sub domains. The cookie is set the following way: Response.Cookies.Append("token", "token value", new CookieOptions { Expires = DateTimeOffset.Now

How to pre-render multiple Vue app pages?

帅比萌擦擦* 提交于 2019-12-11 08:02:15
问题 I'm trying (unsuccessfully) to pre-render the HTML of multiple Vue apps within the same project scaffolded with Vue CLI. I do not want to use Vue Router or Nuxt etc for multiple reasons. I've tried using prerender-spa-plugin, but since I don't use routes, it only pre-renders the index. My vue.config.js looks like this: const path = require('path'); const PrerenderSPAPlugin = require('prerender-spa-plugin'); const Renderer = PrerenderSPAPlugin.PuppeteerRenderer; module.exports = { pages: {

Angular Meta Service not adding and updating dynamic tag values

不想你离开。 提交于 2019-12-11 04:21:01
问题 I'm working on SeoService for my Angular 6 project https://mypleaks.com. I'm trying to add and update Meta tag as my content URL changes dynamically. I'm able to console.log('18 ' + title); console.log('19 ' + description); but when I'm appending title and description in addTag and updateTag tag only static value('myPleaks | ') getting appended, and can be seen on inspecting page sources on this link https://mypleaks.com/#/content/16/Manikarnika-Teaser-Launch-Kangana-Ranaut-Celebrates-with

Error: { Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'fontawesome-webfont.woff2'

女生的网名这么多〃 提交于 2019-12-11 01:58:36
问题 After searching a lot I'm still not able to fix this error in my SSR angular project: Node Express server listening on http://localhost:4000 ERROR Something went wrong please try again later! ERROR { Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'fontawesome-webfont.woff2' Error: Cannot match any routes. URL Segment: 'fontawesome-webfont.woff2' __zone_symbol__value: Error: Cannot match any routes. URL Segment: 'fontawesome-webfont.woff2' And a lot more of error

Server rendered React component class name automatically changed causing styling issue

扶醉桌前 提交于 2019-12-10 18:19:30
问题 I am using React 16 in my personal project (https://github.com/sachinjha1/react-redux-hapi-fullstack-starter/blob/master/package.json). I implemented SSR which works fine on my local. When i test the same app on Heroku all my styling are missing. When i did view source of server rendered html then i noticed that class names are different when rendered from Heroku. Heroku App URL -> https://raxpi.herokuapp.com/ In above heroku url in browser if you check view source you can see that class

Angular 5 Universal (SSR) with dotnet core not working with i18n angular tools on Staging server

耗尽温柔 提交于 2019-12-10 16:06:01
问题 I'm trying to make the Angular Project Template with dotnet core running with the I18n Angular tool. (https://docs.microsoft.com/en-us/aspnet/core/spa/angular?tabs=visual-studio) Here is what I have in my startup class app.Map("/fr", fr => { fr.UseSpa(spa => { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; spa.UseSpaPrerendering(options => { options.BootModulePath = $"{spa

Angular SSR 'Failed to lookup view' on production (Ubuntu, Nginx)

你离开我真会死。 提交于 2019-12-10 15:09:49
问题 Following up the official Angular tutorial on setting up SSR using Express server: https://angular.io/guide/universal#configure-for-universal The tutorial would setup paths like this: ... const DIST_FOLDER = join(process.cwd(), 'dist'); ... app.set('views', join(DIST_FOLDER, 'browser')); This works pretty well on the local server. However once deployed at the server (powered by Nginx), getting the error: Error: Failed to lookup view "index" in views directory "/home/user_name/dist/browser" at