Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CORS for prelude.dhall-lang.org #315

Merged
merged 1 commit into from
Dec 10, 2018
Merged

Conversation

Gabriella439
Copy link
Contributor

@Gabriella439 Gabriella439 commented Dec 9, 2018

The motivation for this is so that the upcoming "Try Dhall" page can
import from the Prelude without being blocked by the browser as a
forbidden Cross-Origin request.

This requires several changes:

First, prelude.dhall-lang.org needs to no longer be a redirect and
should instead act as a reverse proxy using the proxy_pass directive.
This is necessary for CORS to work since a redirect to
raw.githubusercontent.com will cause the browser to check
raw.githubusercontent.com for CORS support instead of consulting
prelude.dhall-lang.org for CORS support.

Second, the recommended proxy settings have to be selectively inlined
to just hydra.dhall-lang.org because they interfere with the
prelude.dhall-lang.org reverse proxy. Specifically, the Host: $host
directive added by the recommended proxy settings becomes
Host: prelude.dhall-lang.org and this confuses GitHub since
GitHub treats any unrecognized Host header as a request to its GitHub
pages functionality.

Third, we need to enable CORS with the correct Access-Control-*
headers.

This also includes a fix to the Hydra patch to work with Nixpkgs 18.09.

This requires several changes:

First, `prelude.dhall-lang.org` needs to no longer be a redirect and
should instead act as a reverse proxy using the `proxy_pass` directive.
This is necessary for CORS to work since a redirect to
`raw.githubusercontent.com` will cause the browser to check
`raw.githubusercontent.com` for CORS support instead of consulting
`prelude.dhall-lang.org` for CORS support.

Second, the recommended proxy settings have to be selectively inlined
to just `hydra.dhall-lang.org` because they interfere with the
`prelude.dhall-lang.org` reverse proxy.  Specifically, the `Host: $host`
directive added by the recommended proxy settings becomes
`Host: prelude.dhall-lang.org` and this confuses GitHub since
GitHub treats any unrecognized `Host` header as a request to its GitHub
pages functiounality.

Third, we need to enable CORS with the correct `Access-Control-*`
headers.

This also includes a fix to the Hydra patch to work with Nixpkgs 18.09.
Gabriella439 added a commit to dhall-lang/dhall-haskell that referenced this pull request Dec 9, 2018
We can import expressions from `https://prelude.dhall-lang.org`
now that it provides CORS support.  See:

dhall-lang/dhall-lang#315
Gabriella439 added a commit to dhall-lang/dhall-haskell that referenced this pull request Dec 10, 2018
We can import expressions from `https://prelude.dhall-lang.org`
now that it provides CORS support.  See:

dhall-lang/dhall-lang#315
@Gabriella439 Gabriella439 merged commit 472dfbd into master Dec 10, 2018
@Gabriella439 Gabriella439 deleted the gabriel/prelude_cors branch December 10, 2018 15:22
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.

None yet

1 participant