Can I use different domains with react-js app - reactjs

I have a web pages constructor.
Every user has opportunity to create web page on my resource.
There are several examples of that pages:
1 https://candylanding.netlify.app/601b1141bfa41700154f7e13
2 https://candylanding.netlify.app/6022ec4641423100151632d7
As you can see the url-addresses of these pages are ugly.
And I am sure that many users want to change it on some beautiful short name (such as DOMAIN.COM)
How can I achieve this? Please give me an idea..
using create-react-app, react-router-dom

Domain allocation is based off of domain ownership, so unless you own DOMAIN.COM users will not be able to use it.
Cloud platform as a service (PaaS) providers like Netlify and heroku use subdomains before the domain to create a clean URL, but you will need access to your server to do this (it won't be possible on netlify)
I think a good first step is allow users to name their route:
ie:
https://candylanding.netlify.app/my-user-site
instead of
https://candylanding.netlify.app/6022ec4641423100151632d7
Once you have that running you can then have a look at this question to dynamically create subdomains:
How to let PHP to create subdomain automatically for each user?

Related

Serve different app on particular subdomain in multi-tenant system

I have built an flask app hosted in App Engine, have used wildcard subdomain mapping along with namespace support provided App Engine so that app will be served from any subdomain. Its all working fine.
Now, I want to make one of the subdomain, say admin.domain.com to handle some admin related activities. All other subdomain points to normal app.
When un-registered user visits company.domain.com, it should be redirected to admin.domain.com where he will register, once done he will go back automatically to company.domain.com.
How to map a admin app to particular subdomain? Is there anyway to do it using Flask or App Engine? If not possible, how to handle this scenario?
This is the first time I am building such a app.
Thanks..
I'm not sure about the semantics when you use the word 'app'. In strict GAE sense, an apps are completely separate, each with its own billing and datastore etc.
If you strictly want to have the admin app as a separate app, you can't use the wildcard subdomain mapping. You'd have to manually map each subdomain using the App Engine admin settings for mapping domains. You can map the admin.domain.com to your admin app, and manually map your other subdomains to the normal app.
If you're just talking about separate admin functionality that runs in the same app, and you're not strictly set on using admin.domain.com, the best way is probably to use the new modules functionality and create your 'admin' as a separate module and use dispatch.yaml to route to it:
https://developers.google.com/appengine/docs/python/modules/routing
Otherwise, Flask/GAE doesn't really provide any built in mechanism for this. You'd have to do something messy like check the URL in every request handler and act appropriately if it's admin.

Is it possible to create myapp in GAE, but disable access from myapp.appspot.com?

If I want to deploy anything on Google Apps, I'll have to create an application in Google App Engine, is that right? Is there a way to use FTP like in other web hosting services?
If I have myapp in GAE, and I already let myownsite.com to use this app. But I don't want anyone else to use this app on myapp.appspot.com, how can I do it?
Thanks in advance!
Perhaps not the best solution, but you can use self.request.headers["HOST"] in your handler to see which domain the request was requested to and redirect the user based on that.
You will need to upload your application. There is no FTP access for that as far as I know, but the GAE SDK contains a commandline tool to do that. You can also do it from IDE.
There is always an associated myapp.appspot.com domain with your application, so no one will take it. But you can also use your own domain (but not for SSL!). But you cannot also block access through myapp.appspot.com, but in Java you can create a filter that will redirect all requests to your custom domain. And keep in mind you cannot use naked domains (without www) in GAE.

Redirecting domain (not google apps) to appengine

I'm building a application that supports different domains. A small CMS that supports different domains.
But what I can't figure out is how to redirect other domains that's outside google apps. I have a domain at google apps, that work's perfectly.
When I create a cname that points at either my appid.appspot.com or www.appsdomain.com it just goes to google.com.
What do I need to do so the other domains point to my appengine application.
..fredrik
You can't just use a cname because google needs to know how to direct the requests through their infrastructure to your app.
You should follow the instructions here: http://code.google.com/appengine/docs/domain.html to set up your name with their infrastructure so that requests to the cname get routed correctly.
Update: You do not have to move your domain to google, only inform them of the names you are going to set up cnames to point to them.
You can do that without a cname.
You need to set up a redirection mechanism of your second domain name. You can do that either by telling your registrar to redirect that url to your Google Apps url (that's how I do it with my registrar, name.com), or you could set up a small [php] script on a server you manage that would receive the queries on the second domain and issue a 301 redirect to your Google Apps domain.
EDIT: It all depends on what you want to do. If you want your app to live at both urls, then this solution will not work. I wrote this in the idea that you want the second url to redirect to your main url, if that's not what you want to do, then issuing redirects won't do the trick.

Many Custom Domains for AppEngine Instance

For our e-commerce service running on AppEngine we would like to offer the option for customers to run the stores on their custom domains (eg: www.mystore.com instead of www.enstore.com/mystore).
From a user perspective, I'd like them to enter the domain name they want to use in their preference screen and tell them how to configure their dns.
I know how you normally add domains to an AppEngine instance (through Google Apps) but I'm not sure you can automate that. And even if that's possible they would be all (hundreds) listed on our google apps page.
Anyone know if this is possible/if there is a good way to do it?
I don't think there is a way to add domains "programatically" to an AppEngine instance. Apparently, domains can only be added by using the Google Apps method that you described. This is confirmed in this SO post: How do i get foo.somedomain.com get handled by myapp.appspot.com/foo on appengine
The only options that pop to mind are the following:
HTTP Redirection
Many DNS providers support HTTP Redirection. In this case, your clients would be able to set up mystore.com and www.mystore.com to redirect to www.enstore.com/mystore. There are some obvious disadvantages with this method that might not be acceptable. First of all, with 301 and 302 redirects, the users will still be forwarded to the registered AppEngine URL: www.enstore.com/mystore, and it will show in their browser. In addition, choosing between a 301 and 302 redirect can make SEO tricky, since you'd have to get into how search engines behave with these redirects. For example most search engines will not use the original URL as a source for keywords when you use a 301 redirect.
In addition to 301 and 302 redirects, some DNS providers (like DNS Made Easy) also provide what they call a "masked hidden-iframe redirect". The page will render inside a hidden iframe, so the URL does not change in the user's browsers. However this makes SEO even more tricky, and it will not allow users to bookmark internal pages, or to reference them easily.
As you can see, this option is less than ideal, but it is one option to consider in some situations. Also note that at the moment, HTTP Redirection using 301 redirects is the suggested workaround for the Naked Domain Issue 777 on the AppEngine issue tracker.
Reverse Proxy
Another option could be to set up a small server somewhere else, like a small Amazon EC2 Instance, and set up a simple reverse proxy. You would be able to set this up very easily, just by using Apache and mod_proxy (or various other alternatives). This would allow you to ask your clients to set up a normal A Record pointing to this instance, while the Apache HTTP server would be acting as a proxy to your AppEngine.
The fundamental configuration directive to set up a reverse proxy in mod_proxy is the ProxyPass. You would typically set it up with one line like these for each VirtualHost (for each client domain):
ProxyPass / http://www.enmystore.com/mystore/
The configuration of the remote proxy could be easily handled by your back-end software.
This is a neater solution which gives you plenty of control - but there are obviously some costs for these benefits. First of all, there is the expense to host the reverse proxy. You would also be adding another point of failure, so you have to add this to your high-availability plan. In addition, if you are serving some pages through SSL it can become quite complicated.
Another option is to have each customer sign up for google apps, and then add your appengine app to their app. That way they can manage the url. They will need to use a cname for this, so urls will be limited to something like 'store.customer.com' You will have to support the multitenancy off of the host-header, but that isn't hard to do given that you already have a way to support multitenancy already. You might want to do the setup for the first couple of clients yourself so you can document the easiest way to set it up.
The rietveld code review app does this as you can add it to your google apps domain. See http://code.google.com/p/rietveld/wiki/CodeReviewHelp#Using_Code_Reviews_with_Google_Apps for more detail.
The preferred option is probably to offer your solution through the Google Solutions Marketplace: http://www.google.com/enterprise/enterprise_marketplace/about.html
We did something similar to Daniel Vassallo second proposal.
We created a python app on the Heroku cloud
(there is no limit for connecting custom domains).
This app is using python requests 1.2.0 lib to get the correct page from your app engine application according to the request domain.
all you need to tell your clients is to put your Heroku app url as their CNAME
For naked domains you can always use wwwizer

How are people using Google App-Engine apps with their own domains?

I've been fooling around with the Google App Engine for a few days and I have a little hobby application that I want to write and deploy.
However I'd like to set it up so that users are not directly accessing the app via appspot.com.
Is hosting it through Google Apps and then pointing it at my own domain the only way to go? I looked at that a little bit and it seemed like a pain to implement but maybe I'm just missing something.
My other thought was to write the app-engine piece as a more generic web-service.
Then I could have the user-facing piece be hosted anywhere, written in any language, and have it query the appspot.com url.
Anyone have any luck with the web-service approach?
The reason Google Apps is required is because you need somewhere to a) verify you own the domain (otherwise, you might point it at app engine, then I might hijack it by adding it to my account) and b) set up domain mappings (which subdomains point to which of your appengine apps).
Since this stuff already exists in Apps, it seems silly to duplicate it in AppEngine.
As has been pointed out, it doesn't cost anything, and you do not need to "move" anything to Google. You simple created a cname record with a random name to verify you own the domain, and a cname for the subdomain you wish to point at App Engine. This only takes a few minutes, and once it's done, it's done forever.
Note: If you host your site elsewhere and use webservices, you need to scale the site/frontend. If you host on app engine, you get this for free :-)
I wrote an article on my blog about redirecting *.appspot.com domains to your custom domain to keep your branding:
http://blog.dantup.com/2009/12/redirecting-requests-from-appid-appspot-com-to-a-custom-domain
To do this, I believe you need to be using Google Apps and have a custom domain setup for Google Apps. Then, you deploy your app into your Google Apps domain.
Here is google's official instructions on how to do that:
http://code.google.com/appengine/docs/domain.html
I have used this process for a couple of sites and it is easy and painless, provided you have control on the DNS records for your domain (you should).
OK, we're now at the end of 2017 and things are a lot different regarding App Engine and custom domains. It's easy now!
Go to the app engine dashboard for your app and choose Settings, then go to the Custom Domains tab. From there, choose Add custom domain.
The tricky part is that Google needs to verify that you control the domain, so they ask you to put a TXT record in the DNS for your domain. Once you do that and Google it, you become "verified" as the owner of the domain.
After that, Google will give you a bunch of A and AAAA (for IP6) records to put in your DNS. Once you've done that, you should be good to go.
It can be easily done using request.getRequestURI() method. If the URL doesn't include your domain, just redirect it to the desired URL using
resp.sendRedirect("<your domain>")
Otherwise load a error page using
request.getRequestDispatcher("<error-page>").forward(request, response);

Resources