Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
I mostly work with Next.js for web projects. Work demands I work on a project that uses Nuxt.js (v2).
I got up to reading on Nuxt. From pouring over the documentation for the last couple of days, there are a few questions that still linger.
Static-Site Generation: I did dabble in it a few months back, but ended up not using it for anything substantial. It seemed fairly straightforward, not much different from using Next.js for purely static-sites using getStaticProps() exclusively for fetching data at build time. Dynamic data fetching and authentication can happen at the client-side very much like it would happen for an SPA. Static data at build time ensures good SEO.
Server-Side Rendering (on Next): For Next.js this was simple as well, every time a page is requested getStaticProps() will block it from rendering until it can resolve with the props data on the server itself. A completely rendered page is returned to the client, from there on out, the client can still call our api routes for immediate dynamic data using XHR.
Server-Side Rendering (on Nuxt): Reading the documentation on Nuxt.js and working out a small sample project, Nuxt.js it seems works differently in SSR (universal), only the first request produces a server-rendered page, here on out, both data-fetching functions, asyncData() and fetch() run on the client-side (javascript bundles for the pages are preloaded using the Nuxt Router).
My question is, what is the benefit of this approach? This will not help out with SEO, secrets can not be stored on the server because the code can execute on the browser. Is there something I am missing? I searched the docs and could not find anything that makes pages render on the server for every request, as a server-rendered application should.
I'm working with Nuxt 3 and as far as I know you can use useAsyncData() and useFetch() in both client and server. Nuxt 3 SSR universal works fine with SEO because crawlers not cache files so every request is separate, so crawlers get every time SSR HTML file from server. You can use secrets if beside web page you want to create API calls from "server" folder, this is separate functionality to make API calls it not marge with web page. Calling this API will send user only for example JSON file, not whole code from a server/*.js files.
Related
We have a CMS where we are trying to provide the support of VueJS framework to our client websites. The views and their logic will be coded from the CMS Panel itself. The problem comes when trying to render the website having the support for both SPA and SSR due to SEO.
When client requests for a page, the SSR should work during that time but once the page is rendered, the SPA should take the control and let the user navigate(vue-router) wihtout page reload as it works in Vue SPA.
I checked on with this question and it won't help due to my unique requirement. There are no static bundles available for my case.
Any help will be appreciated!
I have tried many examples to achive this however they aren't exactly helping for my case.
https://github.com/0x00000001A/vuejs-spa-ssr-vuex
https://github.com/shenron/vue3-example-ssr
You may need nuxtjs. It can help you spa+ssr on vue
I'm studying nuxt.
I leave a question because I have a question while studying.
nuxt can ssr, but ssr is known as server side rendering.
Then, I wonder where the server is.
Because vue is built on node, is the server automatically made into node server?
And, how is SEO possible if we make it with nuxt?
I understand that it is possible if you make html with MPA. However, using nuxt makes SEO possible.
So, when you create a project with nuxt, does the client make it an MPA when it makes the first request?
where the server is?
Depends... Nuxt include a node server (nuxt), but you can during the nuxt instalation merge them with other node server frameworks
when use nuxt alone or with other server-side framework?
Depends of your needs, knowledge and project.
For example I usually use nuxt alone, more apollo graphql it give me all I need. but for Shopify apps, the admin embed login is write for Koa and super easy to use so I prefers nuxt + koa when I develop this kind of app.
what means ssr?
server side rendering, the important thing is Rendering, that means nuxt (or nuxt + extra server-side framework) read the vue (js) code in the server and rendered them in Html code, after that it send the html to the client machine.
This is the reason why SEO is possible, when a web crawler visit the site it receive a fulfilled HTML page easy to read and clasify.
Nuxt has a really extensive and easy to understand guide, I recomend you follow them. Example you can use Head for edit the Header of the page,
I need to develop a Vue.js SPA where some of its pages need to be referenced by search engines.
I've read about multiple ways to make SPAs SEO-Friendly so I found the following solutions
Server-rendered pages
Prerendering
Since we have a lot of dynamic content to index, generating a static page for each "row" in the database seems not acceptable since we have hundreds if not thousands of content pages.
Creating multiple routes (one for users to visualize and one for bots to crawl)
This solution has been proposed by my manager and it interests me since it's more suitable for our case.
I found this article that illustrates the idea using another SPA framework
My question here is how can I detect that a crawler or an indexation bot have accessed our SPA in order to redirect it to our server rendered web pages and how to actually achieve that in Vue.js 2 (Webpack) ?
If you are concerned about SEO, the solution is to use SSR. Read through https://v2.vuejs.org/v2/guide/ssr.html#The-Complete-SSR-Guide.
If you already have server rendered webpages, as you mentioend in your question, then using SSR would be less work than keeping the Vue SPA and server app in sync. Not to mention, if the Vue SPA and server app show different content, this could hurt SEO and frustrate users.
Any method you use to target web crawlers can be by-passed, so there is no generic solution for this. Instead, try and focus on specific web crawlers, like Google's.
For Google, start by registering your app at https://www.google.com/webmasters. If you need to determine if the Google crawler visited your server, look at the user agent string; there are already other answers for that: Is it possible to find when google bot is crawling any urls on my site and record the last access time to a text file on server, https://support.google.com/webmasters/answer/80553?hl=en.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
How do I can create an API with laravel 5, That will be used for login /register for mobile app? Is there any useful tutorial for this type of API.
Like when someone sends a request from a mobile application, I need to authenticate and then send the proper response against that request.
I've made a very simple version in jQuery format as for example and hosted on GitHub.
Here are all the changes from a fresh Laravel: See all changed files
Feel free to adapt to your code.
You can check the step in each commit.
Create the project (Don't forget to run php artisan make:auth)
Make login support AJAX request (instead of auto redirect) 1a47de4
Login with AJAX (submit login data via AJAX, Please CSRF token header) 80be34d
Make register support AJAX (same as step 2) 89f6dd7
Register via AJAX (Same as step 3) ab8d2d7
Use redirect path from Laravel (Bonus) 27b9a1c4
By the way, for the mobile app, you may need to use access token instead. My example is for web app session. Laravel already have the particular method already just twist a bit.
If you need to create a login register with laravel you can simply use the Heto Multi auth.. All the required details are there..
Heto Multi Auth
Hope This will be helpful
There is a popular tool named - Dingo API which is specially created for Laravel / Lumen Frameworks and is meant to provide you, a set of tools to help you easily and quickly build your own APIs.
The package provide you with these set of features:
Content Negotaition
Authentication
API Versioning
Throttling
Formated / Transformed Responses
API Blueprint Documentation
and much more.
You can find the full documentation of Dingo API here >>
Creating a REST Api on Laravel isn’t very difficult. All we need to keep in mind is that where to start and how to prepare RestFull resources. As usual, you can follow this link: Build Rest Resources With Laravel
And if you want that your API works with Mobile Applications you should use tymon/jwt-auth package.
you can find the tutorial to work with laravel and tymon/jwt-auth in this link: Create an API Server for Mobile Apps using Laravel
The tymon/jwt-auth contains:
Installation of the package.
Configuration
Creating Tokens
Authentication
And the link for tymon/jwt-auth package is:
tymon/jwt-auth package
Here is a solution that shows how to set up register/login/logout endpoints but he changes it slighlty so we don't get the nice effects of too many login attempts etc. https://www.toptal.com/laravel/restful-laravel-api-tutorial
I am still looking for a tutorial on how to do this, will share when I find.
I have this reactjs webapp - http://52.26.51.120/
It loads a single page and then you can click links to dynamically load other boards on the same page... such as 52.26.51.120/#/b, 52.26.51.120/#/g
Now the thing is, I want each of these to be an individual page, for the purpose of seo. I want you to be able to google "my-site.com g", and you will see the result 52.26.51.120/#/g. This obviously cant work if you are using reactjs and it is all on one page. Google will only render and cache that main page (can it even render that page? does google execute javascript?)
Even more specifically, id want something like my-site.com/g/1234 to load a thread. There could be a thousand threads every day, so im not sure how to handle that.
Are there any solutions to this? to allow react to possibly serve up static pages as html so that they can be cached on google? I am using expressjs and webpack as my server right now, and all the code is executed in jsx files.
Thanks
You can use Prerender.io service. In a nutshell you will need to connect your server app or web server with prerender service and do little setup (see documentation). After that search engines and crawlers will be served with a static (prerendered) content while users will get classic React.js (or any other single page) app.
There is a hosted service with free tier or open source version
I suspect you could do some smart configuration with nginx and it could convert a url of domain/board to a redirection of domain/#/board when detecting the user-agent as a bot instead of a typical user.