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

Pow Email Confirmation Link Results in 400 Bad Request The plain HTTP request was sent to HTTPS port #647

Open
johns10 opened this issue Sep 21, 2021 · 5 comments

Comments

@johns10
Copy link

johns10 commented Sep 21, 2021

Not sure exactly why, but it's generating a URL of the form:

http://app.user-docs.com:443/confirm-email/{token}

Everything is find. If I navigate directly to that URL, it redirects to the HTTPS endpoint automatically, but clicking it from the email yields a 400. Any ideas?

@johns10
Copy link
Author

johns10 commented Sep 21, 2021

I have some additional information. The ACTUAL link in the form is this:

http://url3648.user-docs.com/ls/click?upn=-2F0tFaQaXMSOTad-2BQXaQAcmo336a9v1p3nnEgtV3BWRGXB7bLT5ZEDzSuPQuIv0XJWrY9nTVtimROn2BsafDigHTFWPvzneXwzdwloG0H2zu-2FB0JmxfVpkX-2Fu0YOZgyUgqF5ITm7gucYaIaYLb-2FMswe5meJCPxc77Y2dsvgJQJW00UCUzRyKxQym0yHusEn6qI1oe2ir6L0F6Ub-2FgDVpZWQ-3D-3DNv6m_8c-2FMmxJbgXlnUvwGL4weMtmdOgyqBueseTqXoiOC43oATpC-2BxR83D6xUl3JXn4JUGCrb7m-2Fi4pyfjh1dHcEeDNAxrLj7qJCISHpLCN9-2FYuwnoi12p3ucmGf12TAQFhZzbUwXMOS9dN2KY6SOnSp-2FYTkdN-2FGtooLAD-2BIzXJBi92AFpnC79QJGSi38xDkcnXr5-2BqppkQ-2FJ5NYCE6i1Vvl033thFWlECS9x2IhAXB7AU8Y-3D

That redirects to the link in the original comment.

@johns10
Copy link
Author

johns10 commented Sep 21, 2021

This is super odd, because in my tests on my local, it generates URL's of the form:

https://localhost:4002/confirm-email/SFMyNTY.MTJjN2VlYTEtYzBhOC00MmE5LWEzOTAtYjcxOTFhZjVhMTFk.veZoe5_7lsNHYO3YL3Cxd0hRUwdJwWRodwhnV1hfkrE

@johns10
Copy link
Author

johns10 commented Sep 21, 2021

Wowzers. I added a log message (LITERALLY IN THE TEMPLATE) and it wound up outputting the following HTML:

<td class="v1btn-link" bgcolor="turquoise" height="40" align="center" >
  Email Confirmation Email html http://app.user-docs.com:443/confirm-email/{token}
  <a href="http://url3648.user-docs.com/ls/click?upn={long_string}" target="_blank" rel="noreferrer"> 
    Confirm your Email Address 
  </a>
</td>

I'm assuming something else is replacing the URL in the email, and that it's not Phoenix.

@johns10
Copy link
Author

johns10 commented Sep 21, 2021

There must be some kind of internal networking going on with my production host, which is handling the translation of url3648.user-docs.com to http://app.user-docs.com:443. The concerning part then: why's it generating http urls on port 443 instead of https. Reason must be the endpoint config of my production host. Maybe because I don't have https configured:

config :userdocs_web, UserDocsWeb.Endpoint,
  http: [port: {:system, "PORT"}], # Possibly not needed, but doesn't hurt
  url: [host: "app.user-docs.com", port: 443],
  check_origin: {UserDocsWeb.OriginChecker, :check, [:prod]},
  cache_static_manifest: "priv/static/cache_manifest.json",
  secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE"),
  server: true

@nikolauska
Copy link

Your endpoint url config is missing the scheme:

url: [scheme: "https", host: "app.user-docs.com", port: 443],

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

No branches or pull requests

2 participants