Skip to content

Automatic subdomain detection #170

Open

Description

@zeke0816

The problem

I have project folders named specifically for subdomains such as foo.acme (foo.acme.test) and Herd sets them up as such —subdomains— automatically. Flock, on the other hand, sets these up by replacing the period with a dash, so I'm left with foo-acme.test as a primary domain.

This is not desirable to me, but, fortunately, there's a workaround: using the domains/alias feature. The issue is that, obviously, I have to manually set it up for each site and I'm left with a domain I didn't want to begin with; and Flock's UI gives me shortcuts to the sites using the primary domain which, again, is not the one I wanted anyway and I have specific reasons to use subdomains.

The solution you'd like

In Herd, these project folders yield subdomains automatically and I don't have to do anything, and it's the only real solution I can think of.

However, I never used Herd's "add site" feature and I'm not planning on using Flock's either as I just create my project via the Terminal on the projects folder I configured so, maybe, there is more to it than just folder naming; i.e., add a subdomain manager (which could work by naming the folders as described before), or add an option to the "add site" feature that specifies if the site is a subdomain (again, I have never even clicked that button yet).

There may be many things to consider here that I can't see because they don't affect me, but the underlying point is to use folder names with periods to quickly and automatically set up subdomains.

Alternatives you've considered

No response

Activity

  1. added theissue type on Nov 14, 2026
  2. added
    help wanted
    and removed on Nov 14, 2026
  3. onairmarc commented on Nov 14, 2026

    @onairmarc
    Member

    Thanks! I've added the help wanted label so this is now open for anyone to implement and submit a PR for!

  4. zeke0816 commented on Nov 14, 2026

    @zeke0816
    Author

    Thank you, @onairmarc! I'll see if I can do it myself on my free time if that's okay with you all!

  5. removed
    help wanted
    on Nov 14, 2026
  6. onairmarc commented on Nov 14, 2026

    @onairmarc
    Member

    @zeke0816 Perfect! I've assigned the issue to you, so no one else can claim it. If you don't have time, let me know, and I'll open it back up to everyone!

  7. zeke0816 commented on Nov 14, 2026

    @zeke0816
    Author

    @lukas-frey Looking at the code, particularly internal/config/config.go and its corresponding test file, I see that site names are sanitized to contain only alphanumeric characters or dashes. Is this by design to prevent issues with working trees, aliases, or whatever else? Should I be wary of this situation? I mean, it seems that Flock was designed to work with aliases for subdomains and not allow periods in site names. My personal argument would be quite the opposite, so I want to make sure I won't be going against Flock's design choices and breaking things. If my approach is not welcome, we can close this issue as won't implement or something similar, and that's okay. Thank you in advance!

  8. lukas-frey commented on Nov 16, 2026

    @lukas-frey
    Member

    Hi @zeke0816, it's not really a design choice. The folder name just had to become a valid hostname, and replacing everything else with a dash was the simplest way. So foo.acme → foo.acme.test is fine with me :)

    Two things to watch out for:

    • Every site also serves its subdomains (up to 4 levels), so an acme site already answers foo.acme.test. The more specific name should win here, same as it already does for aliases (see internal/config/domains.go).
    • Worktrees are named <slug>.<parent>, so a folder foo.acme can end up with the same name as the worktree foo of acme. I'd let the worktree win and show a problem on the other site.
  9. zeke0816 commented on Nov 16, 2026

    @zeke0816
    Author

    Perfect. Thank you for clarifying! I'll make sure to test those special cases. In fact, I can confirm that each site also answers to the subdomains up to 4 levels because that's the exact "issue" I had when switching from Herd.

    I'll see what happens with the levels because if the hostname itself is thought of as foo.acme, to us that's a subdomain but to Flock it would be a hostname that happens to have a period in it (since I'd be redefining SiteName(string) -> string). So, I'll have to test if Flock will allow 1.2.3.4.foo.acme or up to 1.2.3.foo.acme. Feel free to let me know if there's any preference here, because I can see arguments for both being correct.

    I personally think that 1.2.3.4.foo.acme should not be allowed because it would otherwise introduce a loophole to the 4-level rule and I don't intend this to make foo.acme a hostname itself, but a subdomain I can quickly define with my directory structure. For example, I do have directories named acme and foo.acme that serve completely different projects, but I consider foo.acme a subdomain to acme. Then again, I don't think any of the options would cause issues so long as they're defined appropriately.

  10. lukas-frey commented on Nov 16, 2026

    @lukas-frey
    Member

    We can also brainstorm and find another solution for the subdomains, I'm open to ideas.

    The whole reason those 4 levels of subdomains exist is to support wildcard subdomains for tenants (4 was just an arbitrary value chosen to support any kinds of stuff someone might try to do with their app). This could probably also be just an opt-in or something, but if it doesn't hurt anything then I don't see a reason to remove it yet. If it complicates stuff, we can try thinking of something else or if we have another valid reason for it :)

  11. zeke0816 commented on Nov 16, 2026

    @zeke0816
    Author

    Of course, I'm open to brainstorming! Right now, I believe 4 is a sound number and don't intend to change it. I don't even think there's a need for that many subdomains, so it would be a very niche case to have more in my opinion. I vote to keep everything as is and have this change be just a minimal, quality-of-life feature.

    I don't think anything will break, so for now I'll just work on it, test it, and update over here (or directly on the PR) if anything comes up or special cases are to be considered (again, without breaking the cases you mentioned before).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions