How to deploy full-stack app to be able to set http-only cookie from backend? - web-deployment

I deployed frontend on netlify.com and backend on render.com, how I got I can't set cookie from backend because frontend and backend are on different domains.
I found out that I can set sameSite: none, but it makes cookie less secured.
I use two github repositories, one for frontend, one for backend. Will cookies work if I deploy frontend and backend on same web hosting (heroku for instance) as two apps? Or if I do it that way they will be on different subdomains and cookie also will not work? Can I deploy two apps on one subdomain?
Or the only way to deploy is to make repository, containing both of frontend and backend, and deploy from this repository as one app? Is it right?
Any clues and advices are appreciated :)

Related

How to fix problem of mixed content https & http with angular and ASP.NET Core Web API?

I have deployed my backend app made with ASP.NET Core Web API to Smarter Asp and my API is at http://smartapi.com/..... .
I have deployed my frontend app written in Angular to Netlify and my site is: https://astonishing-speculoos-d0b898.netlify.app/
Now, I have a problem that netlify doesn't accept requests with http in its website. How to fix this problem to make my API backend requests work in netlify website?
If you have a look at SmarterAsp's website, it actually seems to be possible to get a free Let's Encrypt certificate.
Link:
https://www.smarterasp.net/free_lets_encrypt_ssl_hosting
When you've added the Let's Encrypt to your hosting plan, you should go ahead and change the URL's for your API calls to include "https://" rather than "http://"

Authentication best practice, frontend is on Vercel and backend is on Heroku?

Application frontend is deployed on Vercel (using next.js) and backend is deployed on Heroku (using express).
I'm setting the httpOnly cookie from the backend, everything is working on development ( on localhost ) but when I deploy my application cookies are not get stored.
I know cookies cannot be set because my domain is different, please let me know what practice to use.
My preference backend and frontend both have to be on different servers. Because I want to use Vercel's CDN to display static pages fast. As of now, Vercel doesn't support custom server deployment.
I want to know the Next.js auth pattern with express server.

nextJS api routes not working with Firebase Hosting

I am having an issue with using Next.js API routes when deploying my website to Firebase Hosting. Here is the api call:
And here is the set up in the pages directory:
Here is the function used in email.js:
I changed the variables as to not give away my email address.
The call works when I use local host. However, when I build and deploy to firebase. I have tried to use the firebase url to make the api call, but I get a 404 page not found. I am not sure how to fix this. I would really appreciate any help.
Firebase hosting only hosts static files which is why your api routes don't work there. If you had a fully static Next site, you could host it on Firebase hosting. But if you want to use the api routes in Next, you need a server. One way to do this (albeit complicated) is to set up Firebase Functions with your api code and then rewrite requests in Firebase Hosting to that Firebase Function. It's complicated because it would require a fairly complex deploy process.
If the rest of your site is static, you can use Firebase Hosting for that and then consider ditching the api routes and instead setting up a Firebase Function to act as your api completely separate from Next.
Or if you want to keep it all in Next, consider something like Vercel for your site + api via Next.

How to put a FIREBASE HOSTING site into maintenance mode?

I have a Vue.js app and use Firebase Hosting to serve the static files to users.
Does Firebase Hosting have a method for putting the app into maintenance mode remotely? Without having to do firebase deploy
Maybe something that will allow me to redirect all the traffic to some other index.html, and be able to manage it from Firebase.
P.S. I've already looked into Firebase Remote Config (and it doesn't fit my use case, and their web related tools aren't fully implemented yet). And I'd like to avoid having a realtime database just for maintenance mode.
There is no mode-switch built into Firebase Hosting for temporarily serving other content.
But given the recent updates to deploy efficiency, it should be pretty low-cost to put up a temporary index.html while making the changes. Alternatively, you could deploy rules (in firebase.json) that temporarily redirect all traffic to a wip.html (for work-in-progress).
Which of these works best, depends on your current content structure. I.e. if you already redirect "all" traffic to index.html, I'd probably go with a rewriting solution.
You can also unroll your last deploy in one command.
Deploy maintenance page
Unroll when its done
Don't forget to send a 503 error for googlebot, asking it to come back in X hours.

Deploy multiple Web Site to one Azure service

I am new to windows azure. I have requirement that I have to achieve. I have searched on the google but it was not useful.
I have to deploy multiple web sites to 1 cloud service. Is there any possibility? I will make them ssl enabled with multiple certificates in one cloud service.
So url's will be like:
https:// mysite/Home/
https:// mysite2/Home/
https:// mysite3/Home/
Actually my requirement is I should be able to deploy multiple web site and able to change the web.config after deployment. I think this we can do by enabling remote machine to the cloud service. After that we can login to remote machine and change the web.config file through iis manager. Am I correct?
Do we have any best way to achieve the requirement? I have to consider the minimum cost for this.
Thanks
This is an old post, but it shows how to run multiple websites in the same web role: http://www.wadewegner.com/2011/02/running-multiple-websites-in-a-windows-azure-web-role/
Regarding the changes in the web.config, you should not do that, because your instances may be changed, and those new instances will not have the modified file. All the configuration you are willing to change after deployment should be stored in the ServiceConfiguration.cscfg file. This way you can modify the configuration without redeploying, and the configuration is shared among all instances of the service.

Resources