W
Wasp5mo ago
Sven

How to not show fly.io domain on google search

Is there anyone that knows a way such that the fly.io domain is not shown in a google search? i have setup my custom domain..
9 Replies
kapa.ai
kapa.ai5mo ago
Hi @Sven. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To prevent your fly.io domain from showing up in Google search results while using your custom domain with a Wasp app, you need to take a few specific steps: 1. Make sure your custom domain is properly set up with Fly.io. Based on the knowledge sources, you should have already: - Added your domain to your Fly client app - Added the proper DNS records (A and AAAA) - Set your custom domain as the WASP_WEB_CLIENT_URL environment variable for your server app Deploying with the Wasp CLI 2. To prevent the fly.io domain from appearing in search results, you should: - Make sure all your internal links use your custom domain, not the fly.io domain - Set up proper redirects from the fly.io domain to your custom domain - Consider adding canonical URL tags in your HTML head to indicate your custom domain is the preferred URL While the knowledge sources don't specifically address hiding the fly.io domain from Google search results, these are standard SEO practices that should help. You might also want to consider: - Using Google Search Console to request removal of the fly.io URLs - Setting up robots.txt on the fly.io domain to discourage crawling If you're using the OpenSaaS template, you might find additional SEO capabilities there, as mentioned by a community member who had success with Google search rankings even without a dedicated landing page: "A lot of hype around needing SSR for good SEO is exaggerated" and Wasp allows you to add OG tags in the head property of the main.wasp file. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
toticozeni
toticozeni5mo ago
@Sven hello, the bot is right, setting up DNS and Canonical URL right should solve the problem for you. Let us know if you have any questions.
NEROX
NEROX5mo ago
To directly eliminate the root of the problem you can create a small redirection middleware:
import { type MiddlewareConfigFn } from 'wasp/server'
import { type RequestHandler } from 'express'
import { URL } from 'url'

const redirectToPrimaryDomain: RequestHandler = (req, res, next) => {
// Use WASP_WEB_CLIENT_URL for the canonical domain.
const primaryDomainUrl = process.env.WASP_WEB_CLIENT_URL
if (!primaryDomainUrl) {
// Allow requests if primary domain is not set (e.g., local dev).
return next()
}

try {
const expectedHost = new URL(primaryDomainUrl).host
const currentHost = req.headers.host

// If the request host doesn't match the primary domain, redirect.
if (currentHost && currentHost !== expectedHost) {
const redirectUrl = `${primaryDomainUrl}${req.originalUrl}`
// 301 Permanent Redirect for SEO.
return res.redirect(301, redirectUrl)
}
} catch (error) {
console.error('Error processing redirect middleware:', error)
// Continue without redirecting in case of error (e.g., invalid URL in env var).
}

// Proceed if hosts match or an error occurred.
return next()
}

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Prepend the domain redirection middleware to the existing middleware chain.
const newMiddlewareConfig = new Map()
newMiddlewareConfig.set('redirectToPrimaryDomain', redirectToPrimaryDomain)
middlewareConfig.forEach((value, key) => {
newMiddlewareConfig.set(key, value)
})

return newMiddlewareConfig
}
import { type MiddlewareConfigFn } from 'wasp/server'
import { type RequestHandler } from 'express'
import { URL } from 'url'

const redirectToPrimaryDomain: RequestHandler = (req, res, next) => {
// Use WASP_WEB_CLIENT_URL for the canonical domain.
const primaryDomainUrl = process.env.WASP_WEB_CLIENT_URL
if (!primaryDomainUrl) {
// Allow requests if primary domain is not set (e.g., local dev).
return next()
}

try {
const expectedHost = new URL(primaryDomainUrl).host
const currentHost = req.headers.host

// If the request host doesn't match the primary domain, redirect.
if (currentHost && currentHost !== expectedHost) {
const redirectUrl = `${primaryDomainUrl}${req.originalUrl}`
// 301 Permanent Redirect for SEO.
return res.redirect(301, redirectUrl)
}
} catch (error) {
console.error('Error processing redirect middleware:', error)
// Continue without redirecting in case of error (e.g., invalid URL in env var).
}

// Proceed if hosts match or an error occurred.
return next()
}

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Prepend the domain redirection middleware to the existing middleware chain.
const newMiddlewareConfig = new Map()
newMiddlewareConfig.set('redirectToPrimaryDomain', redirectToPrimaryDomain)
middlewareConfig.forEach((value, key) => {
newMiddlewareConfig.set(key, value)
})

return newMiddlewareConfig
}
And as Franjo has said, add Canonical as well.
Sven
SvenOP4mo ago
what does this do? i already have some redirect when people come on my fly.io domain or is this somethig different? how do i properly implement this in my code? also i do not understand how i do that Canonical part.... could you dm me @NEROX This did not work? The fly domain still pops up even after canonical and using middleware that gives 301 Probably because the domain has found along time ago by google for example How do i remove this from search results?
toticozeni
toticozeni4mo ago
You should use Google Search Console: https://search.google.com/search-console/about Info about Google Search Console: https://support.google.com/webmasters/answer/9128668?hl=en It always you to track your domain across Google, and also to control it to a degree. In there you can request google crawler to reindex your page, which will update it with new data. But it's not instant. All-around good tool to track some google analytics about your website (but less powerful than e.g. google analytics)
About Search Console - Search Console Help
Google Search Console is a free service offered by Google that helps you monitor, maintain, and troubleshoot your site's presence in Google Search results. You don't have to sign up for Search Console
Sven
SvenOP4mo ago
But where do i put the html Piece of code To verify
toticozeni
toticozeni4mo ago
Customizing the App | Wasp
Each Wasp project can have only one app type declaration. It is used to configure your app and its components.
Sven
SvenOP4mo ago
Wdym with title prporrty?
toticozeni
toticozeni4mo ago
If you are verifying that you own the domain via the <meta> in your websites <head> element. e.g. <meta name="google-site-verification" content="PROVIDED_BY_GOOGLE"> You would add it to your main.wasp like this:
app appName {
// ...
head: [
"<link rel='icon' href='/favicon.ico' />",
"<meta name='google-site-verification' content='PROVIDED_BY_GOOGLE'>"
],
// ...
}
app appName {
// ...
head: [
"<link rel='icon' href='/favicon.ico' />",
"<meta name='google-site-verification' content='PROVIDED_BY_GOOGLE'>"
],
// ...
}
@Sven

Did you find this page helpful?