SSR and CSR confusion
See original GitHub issueHi,
Little confused with proxying requests.
Currently I cannot get both SSR and CSR working at the same time, but can get them working individually.
Request:
return $axios.get( '/pages/123' )
Config:
nuxt.config.js
axios: {
proxy: true,
proxyHeaders: false,
baseURL: process.env.NODE_ENV === 'development' ? 'http://local-api.test/wp-json/wp/v2' : 'https://user:pass@live-api.com/wp-json/wp/v2',
},
proxy: {
'/data/': {
target: process.env.NODE_ENV === 'development' ? 'http://local-api.test/wp-json/wp/v2' : 'https://user:pass@live-api.com/wp-json/wp/v2',
pathRewrite: {
'^/data/': '/'
}
}
},
SSR will correctly fetch 123
route and render. However, if I go to another page and go back to this page and fetch via CSR, then it will request incorrectly to a page, not a endpoint.
However, if I change the request from return $axios.get( '/pages/123' )
to return $axios.get( '/data/pages/123' )
, CSR will work correctly, but SSR will 404 Request failed with status code 404
.
How can I get both CSR and SSR working?
Thanks, Tom
<div align="right">This question is available on Nuxt community (#c257)</div>Issue Analytics
- State:
- Created 4 years ago
- Comments:9
Top Results From Across the Web
Server Side Rendering (SSR) vs. Client Side Rendering (CSR ...
CSR or SSR “rendering” should not be confused with “web page rendering” that is performed by a browser engine (like Webkit, Blink, Gecko,...
Read more >SSR vs CSR: Which Method Works Best? - Growth Rocket
In case you're still feeling confused, it helps to think of SSR as you driving over to the supermarket every time you feel...
Read more >The Ultimate Metaphor for SSR, CSR and Pre-Rendering
I hope that you find this metaphor clear enough and you use it with people who might confuse one or the other. If...
Read more >Server-Side Rendering (SSR) Vs Client-Side Rendering (CSR)
In SSR, when the user makes a request to the webpage, the server prepares the HTML ... The final call is yours whether...
Read more >Understanding Next.js Data Fetching (CSR, SSR, SSG, ISR)
It is quite confusing because when using Create React App, we usually only use 1 strategy to fetch data from API which is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
oh sh*t no, you just made me realize it has been working all along. The proxying is hidden in the background. The errors I got were from the API (just as I wanted) but I did not realize this. 🎉 🎉 => it works!
Thanks so much for you quick answers 😅 I’m very happy again
Haha, no worries dude!