#python #django #vue.js #heroku #django-rest-framework
#python #django #vue.js #heroku #django-rest-framework
Вопрос:
Я смог успешно развернуть свое приложение django / vuejs на heroku. Серверная часть Django использует платформу django rest для обслуживания конечных точек API, в то время как vuejs обрабатывает интерфейс. Я настроил приложение на Heroku, добавил пакеты сборки NodeJS и Python, а затем добавил свои переменные конфигурации. Однако, когда я пытаюсь открыть приложение в браузере, я получаю Not Found. The requested resource was not found on this server.
. heroku logs —tail показывает следующее:
2020-08-28T07:58:53.956114 00:00 app[web.1]: tmp_upload_dir: None
2020-08-28T07:58:53.956114 00:00 app[web.1]: secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
2020-08-28T07:58:53.956115 00:00 app[web.1]: forwarded_allow_ips: ['*']
2020-08-28T07:58:53.956115 00:00 app[web.1]: accesslog: -
2020-08-28T07:58:53.956115 00:00 app[web.1]: disable_redirect_access_to_syslog: False
2020-08-28T07:58:53.956116 00:00 app[web.1]: access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
2020-08-28T07:58:53.956116 00:00 app[web.1]: errorlog: -
2020-08-28T07:58:53.956117 00:00 app[web.1]: loglevel: debug
2020-08-28T07:58:53.956118 00:00 app[web.1]: capture_output: False
2020-08-28T07:58:53.956118 00:00 app[web.1]: logger_class: gunicorn.glogging.Logger
2020-08-28T07:58:53.956119 00:00 app[web.1]: logconfig: None
2020-08-28T07:58:53.956119 00:00 app[web.1]: logconfig_dict: {}
2020-08-28T07:58:53.956119 00:00 app[web.1]: syslog_addr: udp://localhost:514
2020-08-28T07:58:53.956120 00:00 app[web.1]: syslog: False
2020-08-28T07:58:53.956120 00:00 app[web.1]: syslog_prefix: None
2020-08-28T07:58:53.956120 00:00 app[web.1]: syslog_facility: user
2020-08-28T07:58:53.956121 00:00 app[web.1]: enable_stdio_inheritance: False
2020-08-28T07:58:53.956121 00:00 app[web.1]: statsd_host: None
2020-08-28T07:58:53.956121 00:00 app[web.1]: dogstatsd_tags:
2020-08-28T07:58:53.956122 00:00 app[web.1]: statsd_prefix:
2020-08-28T07:58:53.956122 00:00 app[web.1]: proc_name: None
2020-08-28T07:58:53.956122 00:00 app[web.1]: default_proc_name: mysite.wsgi
2020-08-28T07:58:53.956123 00:00 app[web.1]: pythonpath: mysite
2020-08-28T07:58:53.956123 00:00 app[web.1]: paste: None
2020-08-28T07:58:53.956124 00:00 app[web.1]: on_starting: <function OnStarting.on_starting at 0x7f10994d2488>
2020-08-28T07:58:53.956124 00:00 app[web.1]: on_reload: <function OnReload.on_reload at 0x7f10994d2598>
2020-08-28T07:58:53.956125 00:00 app[web.1]: when_ready: <function WhenReady.when_ready at 0x7f10994d26a8>
2020-08-28T07:58:53.956125 00:00 app[web.1]: pre_fork: <function Prefork.pre_fork at 0x7f10994d27b8>
2020-08-28T07:58:53.956125 00:00 app[web.1]: post_fork: <function Postfork.post_fork at 0x7f10994d28c8>
2020-08-28T07:58:53.956126 00:00 app[web.1]: post_worker_init: <function PostWorkerInit.post_worker_init at 0x7f10994d29d8>
2020-08-28T07:58:53.956126 00:00 app[web.1]: worker_int: <function WorkerInt.worker_int at 0x7f10994d2ae8>
2020-08-28T07:58:53.956126 00:00 app[web.1]: worker_abort: <function WorkerAbort.worker_abort at 0x7f10994d2bf8>
2020-08-28T07:58:53.956127 00:00 app[web.1]: pre_exec: <function PreExec.pre_exec at 0x7f10994d2d08>
2020-08-28T07:58:53.956127 00:00 app[web.1]: pre_request: <function PreRequest.pre_request at 0x7f10994d2e18>
2020-08-28T07:58:53.956128 00:00 app[web.1]: post_request: <function PostRequest.post_request at 0x7f10994d2ea0>
2020-08-28T07:58:53.956128 00:00 app[web.1]: child_exit: <function ChildExit.child_exit at 0x7f10994ec048>
2020-08-28T07:58:53.956129 00:00 app[web.1]: worker_exit: <function WorkerExit.worker_exit at 0x7f10994ec158>
2020-08-28T07:58:53.956129 00:00 app[web.1]: nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7f10994ec268>
2020-08-28T07:58:53.956130 00:00 app[web.1]: on_exit: <function OnExit.on_exit at 0x7f10994ec378>
2020-08-28T07:58:53.956130 00:00 app[web.1]: proxy_protocol: False
2020-08-28T07:58:53.956131 00:00 app[web.1]: proxy_allow_ips: ['127.0.0.1']
2020-08-28T07:58:53.956131 00:00 app[web.1]: keyfile: None
2020-08-28T07:58:53.956131 00:00 app[web.1]: certfile: None
2020-08-28T07:58:53.956131 00:00 app[web.1]: ssl_version: 2
2020-08-28T07:58:53.956132 00:00 app[web.1]: cert_reqs: 0
2020-08-28T07:58:53.956132 00:00 app[web.1]: ca_certs: None
2020-08-28T07:58:53.956133 00:00 app[web.1]: suppress_ragged_eofs: True
2020-08-28T07:58:53.956133 00:00 app[web.1]: do_handshake_on_connect: False
2020-08-28T07:58:53.956133 00:00 app[web.1]: ciphers: None
2020-08-28T07:58:53.956134 00:00 app[web.1]: raw_paste_global_conf: []
2020-08-28T07:58:53.956140 00:00 app[web.1]: strip_header_spaces: False
2020-08-28T07:58:53.956651 00:00 app[web.1]: [2020-08-28 07:58:53 0000] [4] [INFO] Starting gunicorn 20.0.4
2020-08-28T07:58:53.957358 00:00 app[web.1]: [2020-08-28 07:58:53 0000] [4] [DEBUG] Arbiter booted
2020-08-28T07:58:53.957462 00:00 app[web.1]: [2020-08-28 07:58:53 0000] [4] [INFO] Listening at: http://0.0.0.0:35680 (4)
2020-08-28T07:58:53.957603 00:00 app[web.1]: [2020-08-28 07:58:53 0000] [4] [INFO] Using worker: sync
2020-08-28T07:58:53.962110 00:00 app[web.1]: [2020-08-28 07:58:53 0000] [10] [INFO] Booting worker with pid: 10
2020-08-28T07:58:53.976659 00:00 app[web.1]: [2020-08-28 07:58:53 0000] [11] [INFO] Booting worker with pid: 11
2020-08-28T07:58:54.051183 00:00 app[web.1]: [2020-08-28 07:58:54 0000] [4] [DEBUG] 2 workers
2020-08-28T07:58:54.631663 00:00 heroku[web.1]: State changed from starting to up
2020-08-28T07:58:55.371826 00:00 app[web.1]: [2020-08-28 08:58:55 0100] [11] [DEBUG] Closing connection.
2020-08-28T07:58:55.371871 00:00 app[web.1]: [2020-08-28 08:58:55 0100] [10] [DEBUG] Closing connection.
2020-08-28T07:58:59.000000 00:00 app[api]: Build succeeded
2020-08-28T07:59:37.638418 00:00 app[web.1]: [2020-08-28 08:59:37 0100] [10] [DEBUG] Closing connection.
2020-08-28T08:01:44.632704 00:00 app[web.1]: [2020-08-28 09:01:44 0100] [10] [DEBUG] Closing connection.
2020-08-28T08:02:29.057508 00:00 app[web.1]: [2020-08-28 09:02:29 0100] [10] [DEBUG] GET /
2020-08-28T08:02:29.413965 00:00 app[web.1]: 10.45.226.51 - - [28/Aug/2020:09:02:29 0100] "GET / HTTP/1.1" 404 179 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"
2020-08-28T08:02:29.414337 00:00 heroku[router]: at=info method=GET path="/" host=ejika.herokuapp.com request_id=74ea00a7-b48f-47b6-bd61-c5ae24e57232 fwd="129.205.143.223" dyno=web.1 connect=1ms service=358ms status=404 bytes=402 protocol=https
2020-08-28T08:02:30.176731 00:00 app[web.1]: [2020-08-28 09:02:30 0100] [10] [DEBUG] GET /favicon.ico
2020-08-28T08:02:30.178965 00:00 app[web.1]: 10.45.226.51 - - [28/Aug/2020:09:02:30 0100] "GET /favicon.ico HTTP/1.1" 404 179 "https://ejika.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"
2020-08-28T08:02:30.179678 00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=ejika.herokuapp.com request_id=58a4a423-8a3b-46ca-98ce-e94ab309d561 fwd="129.205.143.223" dyno=web.1 connect=1ms service=4ms status=404 bytes=402 protocol=https
2020-08-28T08:02:38.080461 00:00 app[web.1]: [2020-08-28 09:02:38 0100] [10] [DEBUG] GET /
2020-08-28T08:02:38.083085 00:00 app[web.1]: 10.45.226.51 - - [28/Aug/2020:09:02:38 0100] "GET / HTTP/1.1" 404 179 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"
2020-08-28T08:02:38.083509 00:00 heroku[router]: at=info method=GET path="/" host=ejika.herokuapp.com request_id=b287270d-130f-4755-91d2-60d4b5fe646b fwd="129.205.143.223" dyno=web.1 connect=1ms service=9ms status=404 bytes=402 protocol=https
2020-08-28T08:03:51.604711 00:00 app[web.1]: [2020-08-28 09:03:51 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:03:57.684130 00:00 app[web.1]: [2020-08-28 09:03:57 0100] [10] [DEBUG] GET /
2020-08-28T08:03:57.693917 00:00 app[web.1]: 10.63.251.11 - - [28/Aug/2020:09:03:57 0100] "GET / HTTP/1.1" 404 179 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"
2020-08-28T08:03:57.696236 00:00 heroku[router]: at=info method=GET path="/" host=ejika.herokuapp.com request_id=15b2e9d5-15b8-4914-be77-14162b38e694 fwd="129.205.143.223" dyno=web.1 connect=0ms service=12ms status=404 bytes=402 protocol=https
2020-08-28T08:05:58.639909 00:00 app[web.1]: [2020-08-28 09:05:58 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:08:05.793569 00:00 app[web.1]: [2020-08-28 09:08:05 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:10:12.847432 00:00 app[web.1]: [2020-08-28 09:10:12 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:11:42.886116 00:00 app[web.1]: [2020-08-28 09:11:42 0100] [11] [DEBUG] GET /services
2020-08-28T08:11:43.146423 00:00 app[web.1]: 10.61.240.57 - - [28/Aug/2020:09:11:43 0100] "GET /services HTTP/1.1" 404 179 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"
2020-08-28T08:11:43.146644 00:00 heroku[router]: at=info method=GET path="/services" host=ejika.herokuapp.com request_id=1a7c47a0-2fc8-463c-8c18-f2a521caf5d3 fwd="129.205.143.223" dyno=web.1 connect=0ms service=261ms status=404 bytes=402 protocol=https
2020-08-28T08:12:19.741009 00:00 app[web.1]: [2020-08-28 09:12:19 0100] [10] [DEBUG] Closing connection.
2020-08-28T08:12:22.798261 00:00 app[web.1]: [2020-08-28 09:12:22 0100] [10] [DEBUG] GET /login
2020-08-28T08:12:22.804687 00:00 app[web.1]: 10.61.240.57 - - [28/Aug/2020:09:12:22 0100] "GET /login HTTP/1.1" 404 179 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"
2020-08-28T08:12:22.805065 00:00 heroku[router]: at=info method=GET path="/login" host=ejika.herokuapp.com request_id=5caa2a62-43ad-49d6-be8f-a577f92afc98 fwd="129.205.143.223" dyno=web.1 connect=0ms service=8ms status=404 bytes=402 protocol=https
2020-08-28T08:14:26.667902 00:00 app[web.1]: [2020-08-28 09:14:26 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:16:33.759216 00:00 app[web.1]: [2020-08-28 09:16:33 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:18:40.682918 00:00 app[web.1]: [2020-08-28 09:18:40 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:20:47.631325 00:00 app[web.1]: [2020-08-28 09:20:47 0100] [10] [DEBUG] Closing connection.
2020-08-28T08:22:54.623126 00:00 app[web.1]: [2020-08-28 09:22:54 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:25:01.706773 00:00 app[web.1]: [2020-08-28 09:25:01 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:27:08.627029 00:00 app[web.1]: [2020-08-28 09:27:08 0100] [10] [DEBUG] Closing connection.
2020-08-28T08:29:15.626468 00:00 app[web.1]: [2020-08-28 09:29:15 0100] [10] [DEBUG] Closing connection.
2020-08-28T08:31:22.739250 00:00 app[web.1]: [2020-08-28 09:31:22 0100] [10] [DEBUG] Closing connection.
2020-08-28T08:33:29.727851 00:00 app[web.1]: [2020-08-28 09:33:29 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:35:36.665915 00:00 app[web.1]: [2020-08-28 09:35:36 0100] [11] [DEBUG] Closing connection.
2020-08-28T08:37:43.476112 00:00 app[web.1]: [2020-08-28 09:37:43 0100] [11] [DEBUG] Closing connection.
Структура моего проекта выглядит следующим образом;
|-frontend(vuejs)
|-django
|-media
|-mysite
|-__init__
|-settings.py
|-urls.py
|-wsgi.py
|-myapp
|-db.sqlite3
|-manage.py
|-.gitignore
|-package.json
|-Procfile
|-requirements.text
Любая помощь в решении этой проблемы будет высоко оценена.
Комментарии:
1. Все ваши
GET url
запросы заканчиваются на ` «GET / HTTP / 1.1» 404 179`, что означает, что он не найден. Вы развертывали на Heroku раньше или используете какой-либо метод для развертывания этого?2. Я развернул Heroku, и общая сборка прошла успешно. поскольку это Django/Vue.js приложение, может ли быть, что vue.js часть приложения не была развернута?