Multiple hosted Websites with only one backend [closed] - firebase

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 months ago.
Improve this question
I want to create several similar webshops and manage everything from one centralized place.
I wouldn't program the backend myself as it would take a lot of time + I don't want to update the security regularly.
I would also not take multiple ready-made template webistes, because it would cost a lot monthly.
So far the best solution I have found would be the following:
I would code the frontend myself with HTML, CSS, JS (+ maybe VueJS) and get the backend as service from Firebase.
Quesiton Nr.1: Have you any better idea?
Quesiton Nr.2:
If this solution is ok, then: is it possible to manage multiple hosted websites with Firebase with one backend? I mean separate domain for each websites, but 1 database and generally only one backend for all webshops?

You can set up one or more Firebase Hosting sites in a single Firebase project. Since the sites are all in the same Firebase project, all the sites can access the other Firebase resources of the project.
https://firebase.google.com/docs/hosting/multisites?authuser=0&hl=it#set_up_deploy_targets
Basically you add a site from the Firebase Hosting console, for example "my-app.web.app".
In the project directory use the following command:
firebase target:apply hosting TARGET_NAME my-app
The target name is only used to help you during the deployment, obviously choose it with a criterion.
The .firebaserc file should look like this:
...
"targets": {
"your-project": {
"hosting": {
"TARGET_NAME": [
"my-app"
]
}
}
}
...
In the firebase.json file you have to transform the "hosting" field into an array and add, in addition to the already existing target, the new one.
...
"hosting": [
...
{
"target": "TARGET_NAME",
"public": "custom_dist",
"ignore": [...],
"rewrites": [...]
}
]
...
At this point to deploy, just use the following command:
firebase deploy --only hosting:TARGET_NAME

Related

How to upload website on Firebase hosting without attaching storage.rules & firestore.rules files?

Today I have uploaded my website on Firebase hosting and in the process of doing that I have to create two rules files, one is storage.rules and another one is firestore.rules. I also have to create a firestore.indexes.json file. But I can remember previously I didn't have to create any such file while uploading another website on Firebas host.
I need to get rid of these 3 files, because every time I upload my files It changed to private rules for both storage and cloud which is unnecessary for me. I need to remain them public. Besides that I can't open these 2 rules files to edit (using Mac) just at least to see what is inside of them. How can I do it, Thanks!
It sounds like you use the Firebase CLI to initialize several products in the same project, including Cloud Storage and Firestore. If you don't want to work with these other products in your project files, you shouldn't select them during initialization.
The easiest thing to do would be to start over in a new directory and initialize only the products you want to use. It sounds like that's only Firebase Hosting.
You could also edit firebase.json and remove the products you don't want to use any more.
If you do want to work with Storage and Firestore, but you only want to deploy to Hosting, then just use firebas deploy --only hosting.

FIREBASE Hosting can't use the correct site

I have the following two hostings set up in my Firebase hosting. I don't know where the first one with the bad name came from, but anyway it's there and it's always coming up when I use firebase init from the command line as the only hosting I can use. Does anyone know how i can use Firebase init to connect my website to the second hosting address, that's the lbdsapp address? Also preferably I'd like to delete the lbds-aeb3d if possible and make the other one the default.F
Any help would be really appreciated. Thanks.
The first site lbds-aeb3d is the main site created from your project ID, When you create the project you probably entered lbds which is too short for a project ID, so some random string is automatically added. So you can not delete it since it's associated with your project.
Since you have added another site, that makes your project a multisites hosting project and you will have to configure .firebaserc and firebase.json accordingly.
You can start by giving your secondary site a name to refer to when you want set it as a deploy target. You can do this by the following command
firebase target:apply hosting <target-name> <resource-name>
In your case, if you call it myapp it would be
firebase target:apply hosting myapp lbdsapp
Then firebase will generate .firebaserc that include myapp as a target
Next, you'll have to define hosting configuration for your site in firebase.json
You will have to add the target name in the hosting config. Note that if you have more sites, you will have to configure hosting as array of config objects
{
"hosting": {
"target": "myapp",
"public": ...,
// ...
}
}
When you deploy your site, you will have to specify the target
firebase deploy --only hosting:myapp

Symfony 4 translation files in directories [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to save translation files in directory, for example:
/translations/admin/messages.en.xlf
/translations/admin/validation.en.xlf
/translations/client/messages.en.xlf
/translations/client/validation.en.xlf
And how to use these translations in Controllers and Twig templates ?
Translation Resource/File Names and Locations
Symfony looks for message files (i.e. translations) in the following
default locations:
the translations/ directory (at the root of the project);
the Resources/translations/ directory inside of any bundle.
The locations are listed here with the highest priority first. That
is, you can override the translation messages of a bundle in any of
the top two directories.
The override mechanism works at a key level: only the overridden keys
need to be listed in a higher priority message file. When a key is not
found in a message file, the translator will automatically fall back
to the lower priority message files.
Source: https://symfony.com/doc/4.2/translation.html#translation-resource-file-names-and-locations
And later on the same page / chapter
You can add other directories with the paths option in the
configuration:
config/packages/translation.yaml
framework:
translator:
paths:
- '%kernel.project_dir%/translations/admin'
- '%kernel.project_dir%/translations/client'
You can use those as any other translation files, remembering the overriding mechanism quoted here above
Full reference: https://symfony.com/doc/4.2/translation.html

Confuse about web hosting CPanel [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
Improve this question
I've read some article about deploying a website to a host. It has something like cPanel and we put all the source code into the public_html folder. And we can access those file using hostname.com/index.html will be pointed to /public_html/index.html file. My question is:
In this case, people can totally access all my source code file inside the public_html directory? It's too dangerous
By the way, some modern web design today is not access page through a file, it's instead by route. For example with Java spring MVC project: if I design a route hostname.com/users will return a page with all user, hostname.com/user/1 will return a json with user no.1. Those are all accessed by url route so how can I deploy that website in cPanel.
Please explain to me if anyone knows. Thank you.
To answer your first question, no. Not technically. Static items such as HTML/CSS/Javascript/Media Files can be accessed if they know the URL (Or you leave the indexing option enabled. Use .htaccess to disable that). PHP files are safe. The only thing people would be able to see is the OUTPUT of those. I would recommend using PHP when creating websites if possible.
You can achieve similar results to your second question be utilizing the .htaccess file and it's rewrite properties. You can also use PHP's POST/GET methods to handle events like you're suggesting.
I hope this helps!
Take a look at the file permissions settings available in cPanel on LAMP:
r = read
w = write
x = execute
You have Owner, Group, & World settings each with read, write, & execute values that can enable fine grained permissions on code, files, & folders on production web servers.

Is it a good practice to use Google Cloud App Engine + Firebase + Cloud Functions to serve HTML cache? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Gev here from Ucraft.
I am reaching out to ask you for some help with ideas on how we can realise the following:
Ucraft is a website builder, built on PHP on the backend, hosted on Google Cloud App Engine.
Now we want to develop a caching mechanism for our public views(Pure HTML hosted in Cloud Storage).
As our frontend websites are multilingual we will need cache for available languages, for which we are thinking to generate HTML cache on a certain step, if cache is not available, using the lang prefix, like Folder: Cache > www.aaa.com > en_GB > index.html/about-us.html…
As out frontend also supports location based layout changes, we will need to generate cache, like this: Cache Folder > www.aaa.com > en_GB > Global > index.html or smth like this: Cache Folder > www.aaa.com > en_GB > uk > index.html, which means that this folder includes cache specific to UK…
#
Scenario: As we need to detect the end user’s location to understand which cache to serve, we are thinking to use Cloud Functions + Firebase. In Firebase we will store DBs that describe if a website has got any location based cache(this will help us to determine the path of the cached folder). In Cloud Functions we want to write a small piece of code, a kind of a tiny load balancer with a logic, that will get the users location from the initial request, check in Firebase, if the website has any location specific cache, if the location of the user and the cache are the same it will serve the cache in the response. If there is no cache available, it will turn to App Engine, Get the HTML, cache it in Cloud Storage, and serve te request
Question: Is this a good practice to store the cache in Cloud Storage as html?
Thank you!

Resources