Skip to content

check domain configuration before starting Invidious#5352

Open
Fijxu wants to merge 4 commits into
iv-org:masterfrom
Fijxu:check-config-domain
Open

check domain configuration before starting Invidious#5352
Fijxu wants to merge 4 commits into
iv-org:masterfrom
Fijxu:check-config-domain

Conversation

@Fijxu
Copy link
Copy Markdown
Member

@Fijxu Fijxu commented Jun 15, 2025

Closes #5351

image

@Fijxu Fijxu requested a review from syeopite June 15, 2025 21:11
Comment thread src/invidious/config.cr Outdated

# Check if the domain configuration is valid
if (domain = config.domain).nil? || domain.empty?
puts "Config: 'domain' is required/can't be empty"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain can be empty on local instances.

Comment thread src/invidious/config.cr Outdated
Co-authored-by: Samantaz Fox <coding@samantaz.fr>
Comment thread src/invidious/config.cr Outdated
exit(1)
elsif parsed_domain = URI.parse(domain)
if domain != parsed_domain.domain
puts "Config: 'domain' is invalid.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
puts "Config: 'domain' is invalid.
puts "Config: 'domain' is invalid."

Comment thread src/invidious/config.cr Outdated
end

# Check if the domain configuration is valid
if (domain = config.domain).nil? || domain.empty?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way you can use String.presence instead of a separate nil/empty check

Suggested change
if (domain = config.domain).nil? || domain.empty?
if !config.domain.presence

@unixfox
Copy link
Copy Markdown
Member

unixfox commented Dec 3, 2025

@Fijxu could you check @SamantazFox reviews :)?

@Fijxu
Copy link
Copy Markdown
Member Author

Fijxu commented Dec 6, 2025

I did something more complicated while testing but this seems to be enough.

$ INVIDIOUS_DOMAIN=https://inv.nadeko.net:8080/meow/asd/meow ./invidious
Config (Hint): Remove the path from your domain: '/meow/asd/meow'
$ INVIDIOUS_DOMAIN=https://inv.nadeko.net:8080 ./invidious
Config (Hint): Remove the scheme from your domain: 'https://'
$ INVIDIOUS_DOMAIN=inv.nadeko.net:8080 ./invidious
Config (Hint): Remove the port from your domain: ':8080'
$ INVIDIOUS_DOMAIN=inv.nadeko.net/asd/asd/asd ./invidious
Config (Hint): Remove the path from your domain: '/asd/asd/asd'
$ INVIDIOUS_DOMAIN=https://inv.nadeko.net ./invidious
Config (Hint): Remove the scheme from your domain: 'https://'
$ INVIDIOUS_DOMAIN=tcp://inv.nadeko.net ./invidious
Config (Hint): Remove the scheme from your domain: 'tcp://'
$ INVIDIOUS_DOMAIN=meow ./invidious
[development] Invidious is ready to lead at http://0.0.0.0:30001

$ INVIDIOUS_DOMAIN=meow.localhost ./invidious
[development] Invidious is ready to lead at http://0.0.0.0:30001

$ INVIDIOUS_DOMAIN=meow.localhost.lol ./invidious
[development] Invidious is ready to lead at http://0.0.0.0:30001

@unixfox
Copy link
Copy Markdown
Member

unixfox commented Dec 18, 2025

Thanks @Fijxu and with empty domain?

@Fijxu
Copy link
Copy Markdown
Member Author

Fijxu commented Feb 16, 2026

Thanks @Fijxu and with empty domain?

INVIDIOUS_DOMAIN="" ./invidious
[development] Invidious is ready to lead at http://0.0.0.0:30001

The Set-Cookie header has no domain property when trying to log in since INVIDIOUS_DOMAIN is empty, as it should be: SID=<some_sid>; expires=Wed, 16 Feb 2028 17:11:37 GMT; HttpOnly; SameSite=Lax, so works fine ;)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Detect and warn on common domain config misconfigurations

3 participants