is it possible to run sails & nuxt on a single express instance? - express

I understand that the intended setup is.
Seperate backend server (e.g. Sails, Laravel, ...)
plus frontend server with nuxt.js or prerendered static content generated with nuxt and statically hosted (e.g. AWS S3, now, ...)
I am wondering if it is also possible to run sails and nuxt within the same node/express instance.

Nuxt.js can be used as a middleware so i think you can. Check the docs: Using nuxt.js programmatically

Related

How can I set Vue environment variables without them being included in the JS files after 'build'?

I'm building a Vue app that works as a SPA that gets rendered by my Express backend.
In this Vue app I'm using environment variables. One of these variables is an API key to an external API service.
Obviously I don't want to show the whole world my API key, however after I run the build command it includes all the env variables in the Javascript files, which I believe makes it accessible to anyone.
What would be the right way to go here? Should I make a route in my Express backend that handels requests to this external API, so that I can safely store my API key on the server side?
Or is there a way to make my Vue app autonomously send requests to the external API without having to show the API key?
I'm using Vue 2 by the way.
Yes you should make a backend that will interact with API using your key instead of the front end doing that no matter which version of VueJs your are using
VueJS is front end javascript, which mean users can see the code even minified on their browser
is what you are looking for
Your could use Nuxt, which is an SSR solution to build your app before shipping it to production. During the build, you can get use some sensible stuff since it will run NodeJS and will be on the server only. That way, you could for example fetch some variables and let's say get the content of some blog articles. Then, it will be available on the frontend with the end result only and all your variables safe since they will be used only on the server build.
Other solution is to use your backend as a middleware to do exactly the same process of using something sensitive and just fetch the end result.
Also, serverless functions like on Firebase or Azure are great + cheap for this purpose.

Can I deploy SSR nuxt.js application on GitHub/GitLab pages?

Is it possible to deploy a server-side rendering application with nuxt.js (universal ssr mode) and firebase backend on GitHub/Gitlab Page? Gitlab gives its example on nuxt, and I wonder if the dynamic fetching on server side still works.
These pages are static, so no server side rendering. You could check the nuxt pre-rendering options: https://nuxtjs.org/blog/going-full-static/, not sure what exactly are the limitations here though.

Next.js with express.js or without express.js?

I have seen many people using nextjs with expressjs and without expressjs framwork. Can someone please explain why do we need expressjs with nextjs? Nextjs works as SSR without expressjs. What does expressjs add to nextjs when we use it together? Assuming that we are using different rest api server.
You don't need to use expressjs if all you want is server-side rendering. But if you want to go beyond that by adding an API, as an example, then you need to be able to override the routing and that's when you'd add expressjs in front. Express will get the request and see if it is for the API or if it's just a normal nextjs page. LogRocket has a very good tutorial on this https://blog.logrocket.com/how-to-build-a-server-rendered-react-app-with-next-express-d5a389e7ab2f/
You most likely don't need to override Next's default server. For edge cases where you do, you'll see examples showing a custom server extending Next's default. You can use whatever server framework you want – Express, Hapi, etc.
https://nextjs.org/docs/advanced-features/custom-server

Differences and use of vuexpress, VuePress and vue-server-renderer modules of Vue.js

I came across vuexpress, vuepress and vue-server-renderer. To me these are looking somewhere similer which I guess are not. I am not frontend developer so not able to understand exact difference and use of these three modules.
Their official sites are saying
https://github.com/vuexpress/vuexpress
vuexpress: Vue + Express.js = VueXpress / A server side rendering
engine for Express.js. Use .vue files as your express.js templates.
https://vuepress.vuejs.org/
VuePress: Vue-powered Static Site Generator
https://ssr.vuejs.org/
vue-server-renderer: server-rendered Single-Page Applications using
Node.js as the server.
vuepress and vue-server-renderer are official library from Vue.js
So what exactly are differences and use of these three modules?
The idea with Vue (from the perspective of your question) is that you create a single-page application.
vuexpress is a rendering engine you can use in an Express application if you want to use the Vue syntax to implement your Express views, i.e. you implement a dynamic website and use the Vue syntax.
vuepress is about building a single-page application in Vue that also prerenders each page (and some other goodies, such as using markdown) to improve initial page load and facilitate for search engines. It is primarily used for websites with static content, such as documentation.
The point with a Vue application is to run it on the client (in the web browser). With vue-server-renderer you can run it on the server to obtain the HTML code the web browser would render if it would run in the web browser, and send it to the web browser, so the web browser doesn't need to run your Vue application, but receives the HTML it would display instead. Why? To improve initial page load and facilitate for search engines. I imagine vuepress makes use of vue-server-renderer under the hood.

Does nuxt need a server?

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,