microsoft / vscode-dev-containers

NOTE: Most of the contents of this repository have been migrated to the new devcontainers GitHub org (https://github.com/devcontainers). See https://github.com/devcontainers/template-starter and https://github.com/devcontainers/feature-starter for information on creating your own!
https://aka.ms/vscode-remote
MIT License
4.72k stars 1.41k forks source link

Add `app.github.dev` to `RAILS_DEVELOPMENT_HOSTS` #1626

Closed joshaber closed 1 year ago

joshaber commented 1 year ago

Codespaces is migrating port forwarding to live under app.github.dev so we need to update the default RAILS_DEVELOPMENT_HOSTS to reflect that.

ghiculescu commented 1 year ago

@joshaber I thought you might want to know that this out of the box config doesn't seem to be working on new codespaces on the current Rails release. I think it has not worked since https://github.com/rails/rails/commit/0fccfb9a3097a9c4260c791f1a40b128517e7815 though it may be earlier.

Here is a test that shows the issue: https://github.com/rails/rails/compare/main...ghiculescu:rails:codespaces-bug

The [".githubpreview.dev", ".app.github.dev"] comes from the Dockerfile via the RAILS_DEVELOPMENT_HOSTS env var (PR), and "ghiculescu-urban-lamp-asdfasdgsafda-3000.preview.app.github.dev" is the (lightly sanitized) URL of my codespace.

It looks like because it is a sub-subdomain it isn't permitted. I mentioned this to someone else who regularly does Rails development on codespaces and he said "oh yeah you have to add config.hosts", which is fine, but given there was a lot of work put into making it work out of the box I thought you might want to know.

Thanks for all your work on Codespaces!

cc @dmilburn

ghiculescu commented 1 year ago

I wrote all that post and then I realised the fix was just to add this config:

config.hosts << ".preview.app.github.dev"

Perhaps that could be added to the template?

joshaber commented 1 year ago

@ghiculescu great catch, thank you for pointing it out! I've opened https://github.com/devcontainers/templates/pull/83 and https://github.com/devcontainers/images/pull/262 to resolve it.