-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add a custom CORS proxy for our clients #681
Conversation
|
||
ctx.status = response.status; | ||
|
||
for (const header of headersToPass) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the only place where headersToPass is used. Maybe it's better to inline it here? Will be more readable. [...].forEach((header) => {})
|
||
if (typeof origin !== 'string') { | ||
if (!allowedOrigins.includes('none')) { | ||
throw new BadRequestException('Missing origin'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status 400 means that user has a chance to fix the situation. But it's not the case as origin is not manually chosen.
We need some other Status I believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we have any better option. It is the client error (definitely not the server one), i.e. some of the 4xx codes. The 400 means 'some problem with the request that we can't specify more clearly by other 4xx codes'.
Of the other codes, only the 403 is more or less fits.
28cf81d
to
f540bfa
Compare
Added
GET /v2/cors-proxy?url=...
. This method acts as a simple proxy for web clients that need to make requests to other origins (specifically, to oEmbed endpoints of media providers). The proxy is deliberately limited: the valid request origins and URL prefixes are defined in the server config (see the corsProxy config entry).