Firebase Dynamic Links with Subdomain - firebase

I have successfully configured Firebase Dynamic Links with my own domain at a link like this:
https://example.com/links/
On example.com I can serve my site (through Firebase Hosting) without any problems, and on example.com/links I have my dynamic links. Everything went smoothly there, I had to add this to my firebase.js:
"rewrites": [
{
"source": "/links/**",
"dynamicLinks": true
}
]
What I want to do now, is have the same thing but on links.example.com subdomain in place of the /links path. This should be possible according to Firebase's docs, but when I try to create the URL prefix in the Console it asks me to add this to my firebase.js:
"rewrites": [
{
"source": "/**",
"dynamicLinks": true
}
]
I tried that, and the Dynamic Links do work, but my whole site is treated as a dynamic link now, even when using example.com without the links. subdomain.
Am I missing something here? Something I can add to the firebase.js or configure in the Console to only treat the subdomain as a Dynamic Link?

You would want to create an additional Hosting site in your project for the subdomain rather than add an additional subdomain to your existing site. On that site, you could deploy just the dynamic links config without any additional files.
There is no way to configure a single Firebase Hosting site to serve different content based on the domain.

Related

How do I route a subdomain to a NextJs route

I have a NextJs app with 2 routes (/ and /blog) configured as:
pages/index.tsx
pages/blog/index.tsx
When I deploy them on vercel, everything works fine but I want to have a subdomain for /blog like blog.example.com. So whenever an user goes to blog.example.com, I want to redirect them to example.com/blog. So in my registrar I added blog as cname and in my vercel, I added that subdomain. But the problem is vercel doesn't show any options for this redirection. It only allows redirections to other domains or to a different git branch but not to a domain with a route.
Basically I want to route blog.example.com to example.com/blogon my vercel config. But Vercel doesn't allow me to add a route along with the domain.
In my registrar, my dns is configured as following:
example.com A <some ip>
blog.example.com CNAME cname.vercel-dns.com.
www.example.com CNAME cname.vercel-dns.com.
So what are my options? I know I can just create 2 different projects, one for / and one for /blog and use monorepos but it seems like an overkill as my / webpage is very simple.
Edit:
Found an answer where they suggest using wildcard domains on vercel and then in the NextJs app, parsing the url, and then doing the redirection... which is fine, I guess. But it seems a bit hacky? Shouldn't this redirection logic be done in the cloud management side and not within my webapp?
So looks like I was approaching it from the wrong end. The registrar, in my case google domains, allows domain forwarding. So I removed my sub domain from the cname and added it here. Problem solved.

Vercel custom domain returning: Not Found - Request ID:

TL;DR: I have a next js website that is working on all vercel domains (production, and preview domains). When I try to use a custom domain they return a page that looks like the screenshot below:
Vercel domain: https://tasmto.vercel.app/
Custom domain: http://www.tasmto.com/
GH repo: https://github.com/tasmto/portfolio/
The site is in a subfolder named web but I have already configured that on vercel and I've made sure Next.js is the selected framework.
What I've tried so far:
Pointing the domain through an A-record and using nameservers.
Deleting the entire vercel project and trying again.
Pointing a subdomain to the app instead off myt apex domain.
Redeploying the app.
The site works when I use 100% Netlify but for some reason Vercel just doesn't want to serve an already working site to my domain and I am stump'd.
Thank you so much in advance (any advice or ideas will help).
PS: I know variations of this questions have been asked but either I'm too dense to apply the solutions or I've misconfigured something else somewhere.
Ok, after sleeping on it here is what finally worked for me.
(Optional) I added a now.json with the contents below.
Because I was using the nameserver option I went into the domain settings inside of vercel and added the pre-existing A record again (as if I wasn't using the nameservers at all.
Now.json contents:
{
"name": "portfolio",
"alias": [
"tasmto.com",
"www.tasmto.com"
]
}
If this doesn't fix it have a look at this stackoverflow question.

Is it possible to use Vercel (Next.js) + WordPress on other webserver using reverse proxy to mask URL?

I'm trying to build my app using next.js, deploy on Vercel (mydomain.com) and have a path called "/blog" that would pull my blog.mydomain.com under mydomain.com/blog.
I was able to do it changing the WP site URL, but only the home will be available, so if I try to access, for exemple, mydomain.com/blog it's OK, but if I go one path down It will redirect to the original blog domain.
mydomain.com/blog -> OK, the URL is masked and it will show my WP under vercel domain.
mydomain.com/blog/hello-world -> redirects to blog.mydomain.com/hello-world
I've read a lot of documentation on vercel/next.js, I've also tried using reverse proxy, but my lack of experience with webservers made it very hard to achieve the expected result.
I've found many answers, but none of them could apply to Vercel + External WP, so I hope you could bring some light so I can see what am I missing...
Thanks!
I had similar issue with wordpress blog under blog.example.com. It turns out the blog was adding / at the end of the nested routes. I solved it with following code in the vercel.json:
"rewrites": [
{
"source": "/blog",
"destination": "https://blog.example.com"
},{
"source": "/blog/:match*",
"destination": "https://blog.example.com/:match*/"
}
],

Firebase Hosting hosted website with custom domain not loading with www prefix

I own a domain through GoDaddy with the .app extension (call it mydomain.app). I have a site hosted on Firebase Hosting for this domain and it works fine. However, the website only loads through https://mydomain.app and not https://www.mydomain.app. I have the DNS properly configured according to GoDaddy tech support and wonder if I'm supposed to explicitly add www.mydomain.app in Firebase hosting in addition to mydomain.app? Seems redundant. Or is this not necessary and I have a configuration problem on my hands?
Go to GoDaddy, where you added your A record to point to Firebase the first time.
Since it's working, that means you configured it to use
# ==> your FirebaseAppUrl.
Under it, now, add also another A record, to configure your www.mydomain.com,
by adding www A record, to point to the same place.
www ==> your FirebaseAppUrl.
Keep both records of course in GoDaddy.

Netlify Custom Domains and WordPress admin access

Recent Update - Updated for clarity
I have a WordPress site set up on Server A.
Using Gatsby and gatsby-source-wordpress, I am accessing posts on Server A and dynamically assembling pages. I am then deploying a Gatsby site to Netlify.
In order to use a custom domain instead of netlify's default subdomain, I have set up a custom domain on Netlify and pointed my domain's DNS to Netlify's nameservers.
The problem is when I navigate to mycustomdomain.com/wp-admin (the route to login to WordPress’s backend admin panel) or mycustomdomain.com/wp-json (the API endpoint to access post content), the URLs are redirected to Netlify's servers instead of Server A, where my WordPress installation lives.
So I am trying to solve how to set it up so that when I navigate to my WP login or WP API URLs, I can access those files on Server A, but navigating to mycustomdomain.com goes to my Gatsby/Netlify build.
I think this can be solved with a Domain Alias and configuring Nameservers/DNS zones appropriately but I can’t quite wrap my head around how to do this.
Thanks,
Below is not the right way but maybe it will help you.
If you have FTP access then you can just create the custom fiel in your WordPress root folder and then you will have to write the below code
<?php
include "wp-load.php";
wp_set_auth_cookie($your_user_id); // generally 1 for the main admin user
?>
Run your newly created file like below http://example.com/custom_file.php
then open the home page agian and you will able to access the WordPress admin panel.
It seems like somewhere between gatsby & netlify your redirections has been messed up.
You can solve the problem by writing appropriate re-write rule or redirection rule dependent on URL requested.
Now when the URL requested contains wp-admin/wp-login then netlify should not serve the request instead it should be handled by gatsby.
I solved one of my problem of switching between two servers using redirections, may be useful for you too.
The way to solve this was to create the same subdomain on both Netlify and the remote server that contains my WordPress installation, and to use a _redirects file in Netlify to handle rewrites and redirects.
For example, I'll create wp.mydomain.com as my subdomain.
Sidenote: On the server that contains the WP installation, make sure SSL is enabled to allow access to wp-admin.
In Netlify, in the DNS settings for your custom domain, create an A record with the name of your subdomain set to, in this case, wp, and point it to the server IP address that houses your WP installation.
Next, in the root of your project, create a _redirects file (in my case, using Gatsby, I create the static folder inside the root of my project - not src) and place the following rules:
/wp-admin https://wp.mydomain.com 200
This says that anytime I access www.mydomain.com/wp-admin redirect me to wp.mydomain.com/wp-admin, the subdomain I set up on my WP server. This routes my request to my WP server and not Netlify.
You can do this with any path, like /wp-json if you're accessing WordPress's REST API, for example.
This was a pain to get working. I hope it helps someone out there!

Resources