Open
Conversation
mbuhot
approved these changes
Feb 10, 2019
| /deps | ||
| erl_crash.dump | ||
| *.ez | ||
| .idea/ |
Contributor
There was a problem hiding this comment.
I suggest ignoring IDE generated files globally in your git config so they don’t need to be ignored in each repo.
|
|
||
| swagger_map = | ||
| if scheme == "https" do | ||
| Map.put_new(swagger_map, :schemes, ["https", "http"]) |
Contributor
There was a problem hiding this comment.
Is plain http included for local development, even if the production endpoint is always https ?
maysam
approved these changes
Jun 21, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When handling url schemes (http/https), phoenix swagger currently does only take into account if there is set up a
:httpsserver in the endpoint config. Instead, it should first lookup if under the endpoint:urlconfig a custom scheme is defined.Problem
Currently, phoenix swagger is generating the base url with scheme “https” only if in the phoenix
endpoint_configit is set as distinct:httpsserver. (see https://github.com/xerions/phoenix_swagger/blob/master/lib/mix/tasks/swagger.generate.ex#L178) Thecollect_host_from_endpoint. It does not consider the endpoint:urlconfig, in particular it ignores:scheme(see below).On the other side, it is a common scenario to run one's application behind a (https) reverse proxy. It is therefore in the general interest, to allow generating https base paths for the client communication – although the phoenix server is running only in https.
The phoenix docs are clear on the issue. It says that
:urlis for “generating URLs throughout the app”. https://hexdocs.pm/phoenix/Phoenix.Endpoint.html Moreover, the docs explicitly mention the reverse proxy issue:The :scheme option accepts "http" and "https" values. Default value is infered from top level :http or :https option. It is useful when hosting Phoenix behind a load balancer or reverse proxy and terminating SSL there.This PR alters the behavior of phoenix swagger to that extent, that first the configuration in
:urlis taken into account.