cookiecutter / cookiecutter-django

Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
https://cookiecutter-django.readthedocs.io
BSD 3-Clause "New" or "Revised" License
12.03k stars 2.88k forks source link

Add ngrok for developing locally with HTTPS #5184

Closed hugomoran159 closed 2 months ago

hugomoran159 commented 3 months ago

Description

Change the documentation for developing locally with HTTPS to use ngrok.

Rationale

The existing documentation no longer works as described.

Implementation

ngrok allows a user to connect localhost to the internet for testing applications and APIs

  1. Install ngrok
  1. Register for account - get AUTH_TOKEN

  2. ngrok config add-authtoken <AUTH_TOKEN>

  3. ngrok http localhost:8000 - get URL

  4. In config/settings/local.py

ngrok URL should now serve localhost

foarsitter commented 3 months ago

Just curious, why do people want to develop locally with https?

hugomoran159 commented 3 months ago

I needed to use the quickbooks production api to pull transaction data for my company. It required https otherwise it only let you use sandbox accounts which don't have any of the real data. I think a few other APIs also require https.

browniebroke commented 3 months ago

The existing documentation no longer works as described.

Yes, it's been like this almost since it was added (https://github.com/cookiecutter/cookiecutter-django/issues/2840). Having it in a docs was a mistake, we should either support it as first party or not. The current docs might be a good exteranl blog post, but I have no interest in maintaining it.

We had a PR sent to "fix" them #3111 but sadly it's included a lot of changes which are too out of scope...

AksAman commented 2 months ago

Just curious, why do people want to develop locally with https?

  1. Few social auth providers only support https callback urls.
  2. While working with payment gateways, most of them need a publicly accessibly https endpoint for webhooks.
AksAman commented 2 months ago

Though in my opinion, prefer using cloudflare tunnels as it's free and provides custom subdomain using your dns records. Makes it easier than ngrok where the subdomain keep changing on every run (on the free plan).

foarsitter commented 2 months ago

https://webhook.site/ can do a XHR Redirect to your localhost

Though in my opinion, prefer using cloudflare tunnels as it's free and provides custom subdomain using your dns records. Makes it easier than ngrok where the subdomain keep changing on every run (on the free plan).

Imho is the point not which tunnel to use (ngrok or cloudflare) but the configuration required for letting django accept https in combination with local development and stuff like csrf.

Afrowave commented 2 months ago

The existing documentation no longer works as described.

Yes, it's been like this almost since it was added (#2840). Having it in a docs was a mistake, we should either support it as first party or not. The current docs might be a good exteranl blog post, but I have no interest in maintaining it.

We had a PR sent to "fix" them #3111 but sadly it's included a lot of changes which are too out of scope...

I am sorry @browniebroke and fellow Djangonista,

I recently updated my local HTTPS set up with a mind to clean up the docs. I hope to do that until everyone is happy. I have some free time to this.

My plan is to remove the current instructions, write an blog post on my site with all the options available to Cookiecutter Django for a local HTTPS environment and link the article to the docs.

The other option is to make it a first class option. This means adding it to the project setup as an option and have it working from the get go.

What do you guys think?

foarsitter commented 2 months ago

If we can add https to local development that works out of the box, I think having it as a first class option would make sense. Nobody is deploying to production without https anymore these days. Having a development environment with https involved would make sense.