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

redirect and CORS policies #11223

Closed
rouault opened this issue Mar 15, 2024 · 9 comments
Closed

redirect and CORS policies #11223

rouault opened this issue Mar 15, 2024 · 9 comments
Labels
Accepted Accepted issue on our roadmap Support Support question

Comments

@rouault
Copy link

rouault commented Mar 15, 2024

Details

Issue

We have setup an "exact redirect" from /schemas/* to /en/latest/schemas/:splat using HTTP 302.
so that URLs like https://proj.org/schemas/v0.7/projjson.schema.json get resolved to https://proj.org/en/latest/schemas/v0.7/projjson.schema.json
However the "from" URL cannot be used in context where CORS is needed

https://www.test-cors.org/#?client_method=GET&client_credentials=false&server_url=https%3A%2F%2Fproj.org%2Fschemas%2Fv0.7%2Fprojjson.schema.json&server_enable=true&server_status=200&server_credentials=false&server_tabs=remote returs a "Fired XHR event: error"
whereas https://www.test-cors.org/#?client_method=GET&client_credentials=false&server_url=https%3A%2F%2Fproj.org%2Fen%2Flatest%2Fschemas%2Fv0.7%2Fprojjson.schema.json&server_enable=true&server_status=200&server_credentials=false&server_tabs=remote works with "Fired XHR event: load"

Is there a way to setup a redirect that is CORS friendly? Or replicate content that is under the /en/latest/foo/bar hierarchy as non-versioned content at top level /foo/far in a non-redirected way?

This is related to OSGeo/PROJ#4088

@humitos
Copy link
Member

humitos commented Mar 19, 2024

Hi, thanks for opening this issue. What would be needed on the Read the Docs side to support CORS on the redirect?

@humitos humitos added Support Support question Needed: more information A reply from issue author is required labels Mar 19, 2024
@humitos
Copy link
Member

humitos commented Mar 19, 2024

Do we need access-control-allow-origin: * on the 302 response?

@rouault
Copy link
Author

rouault commented Mar 19, 2024

Do we need access-control-allow-origin: * on the 302 response?

@m-mohr Can you answer this ?

@m-mohr
Copy link

m-mohr commented Mar 19, 2024

Yes, as far as I know we need:

Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location

@humitos

@humitos humitos added Feature New feature Needed: design decision A core team decision is required and removed Support Support question Needed: more information A reply from issue author is required labels Mar 19, 2024
@jorisvandenbossche
Copy link

Not directly related to the topic about redirecting here, but for the original use case from PROJ that triggered this issue: I was wondering if readthedocs supports hosting some static files at a specific location, independent from the automated builds and related version / url scheme?
i.e. for this specific case, is there a way to host a file at https://proj.org/schemas/v0.7/projjson.schema.json, without it having to redirect to one of the doc versions at https://proj.org/en[latest/stable/9.3/..]/

I didn't directly find anything about this in the readthedocs documentation. But if not possible through readthedocs itself, does readthedocs still allow this to be done by the person managing the proj.org server/domain? (or do the redirects conflict with that?)

@humitos
Copy link
Member

humitos commented Mar 25, 2024

@jorisvandenbossche

is there a way to host a file at proj.org/schemas/v0.7/projjson.schema.json, without

If I understand correctly, what you want is to remove the "language" part from the URL? Is that correct?

If that's the case, the documentation about this is at https://docs.readthedocs.io/en/stable/versioning-schemes.html

You can go to your project's setting and enable it:
Screenshot_2024-03-25_16-31-51

@jorisvandenbossche
Copy link

Not exactly, what I meant is: for a project that is using the "multiple versions with/without translations" scheme, i.e. where URLs for the documentation artifacts start with eg /en/latest/, to separately also host some files outside of that url scheme (not part of one of the documentation versions)

@humitos
Copy link
Member

humitos commented Mar 25, 2024

No, it's not possible to host files outside of the documentation versions.

@humitos
Copy link
Member

humitos commented Mar 25, 2024

Yes, as far as I know we need:

Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location

I added these headers to your project's domain:

$ curl -s -I https://proj.org/schemas/v0.7/projjson.schema.json | grep access-control
access-control-allow-origin: *
access-control-expose-headers: Location

I checked with the links from the original description and both return the same response now. I'm closing this issue, but let me know any feedback you may have and we can reopen the issue if required.

@humitos humitos closed this as completed Mar 25, 2024
@humitos humitos added Support Support question Accepted Accepted issue on our roadmap and removed Feature New feature Needed: design decision A core team decision is required labels Mar 25, 2024
humitos added a commit that referenced this issue Mar 25, 2024
humitos added a commit that referenced this issue Mar 26, 2024
* HTTPheader: add another option

Required by #11223

* Add missing migration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Support Support question
Projects
None yet
Development

No branches or pull requests

4 participants