Skip to content
Sign upLog in
← Back to Community

How to link a wildcard domain to flask?

Profile icon
iWarozHacker

I am trying to make a website for people to create profiles, with the url for a site to be .domain.com instead of domain.com/username, and so I set a wildcard CNAME record on namecheap, but when I try visiting a page, it just says "Run The Repl", unless I specifically linked that subdomain before.

I don't want to link every single useable subdomain, but when I type *.domain.com into the link domain menu it takes much longer than a just putting a subdomain.

Any ideas?

Voters
Profile icon
iWaroz
Comments
hotnewtop
Profile icon
OneNose

Try something like this (replace app with your Flask object):

@app.route("/", subdomain="<username>") # now the subdomain will be passed into the parameter 'username' def profile(username): return "Hello " + username + "!"

Then you can enter iWaroz.domain.com. The output would be Hello iWaroz!

Profile icon
iWaroz

@OneNose
The problem isn't with detecting the subdomain, but getting traffic from all subdomains to the repl, but I talked with a replit dev and turns out the problem is with the dns servers. Otherwise, I didn't know about the subdomain="" argument in flask which is better than my regex-based solution with flask.request.url

Profile icon
charan200415

@iWaroz
please tell me how u linked wildcard domain to replit pls tell pls help me pls pls pls

Profile icon
iWaroz

@charan200415
Thats the thing, never managed to :/ sorry

Profile icon
charan2004155

@iWaroz
can't understand what u told

Profile icon
iWaroz

@charan2004155
The way replit works is that you simply can't do a wildcard domain linking, or at least you won't be able to until replit makes a change to their systems. Things might have changed since this post but I don't think they have.

Profile icon
charan2004155

@iWaroz
thank u for reply