Заголовки Cross-Origin Resource Sharing (CORS) не добавляются в ответы
Заголовки кросс-оригинального обмена ресурсами (CORS) не добавляются в ответы, внутрибраузерные запросы к моему приложению Django из других источников не представляются возможными. Я следовал инструкциям здесь на PyPi без какой-либо помощи. Я включил консольную область, которую я получаю. https://pypi.org/project/django-cors-headers/
Я хочу получить json-файл.
Ошибки консоли:
Access to fetch at 'http://localhost:8000/api/cats' from origin 'http://127.0.0.1:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
App.vue:59 GET http://localhost:8000/api/cats net::ERR_FAILED 301
fetchcats @ App.vue:59
_createElementVNode.onClick._cache.<computed>._cache.<computed>
@ App.vue:29
callWithErrorHandling
@ runtime-core.esm-bundler.js:155
callWithAsyncErrorHandling
@ runtime-core.esm-bundler.js:164
invoker
@ runtime-dom.esm-bundler.js:339
runtime-core.esm-bundler.js:38 [Vue warn]: Unhandled error during execution of native event handler
at <App>
warn2
@ runtime-core.esm-bundler.js:38
logError
@ runtime-core.esm-bundler.js:212
handleError
@ runtime-core.esm-bundler.js:204
(anonymous)
@ runtime-core.esm-bundler.js:167
Promise.catch (async)
callWithAsyncErrorHandling
@ runtime-core.esm-bundler.js:166
invoker
@ runtime-dom.esm-bundler.js:339
App.vue:59
Uncaught (in promise) TypeError: Failed to fetch
at Proxy.fetchcats (App.vue:59:28)
at _createElementVNode.onClick._cache.<computed>._cache.
<computed> (App.vue:29:18)
at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:164:21)
at HTMLButtonElement.invoker (runtime-dom.esm-bundler.js:339:9)
fetchcats
@ App.vue:59
_createElementVNode.onClick._cache.<computed>._cache.<computed> @ App.vue:29
callWithErrorHandling @ runtime-core.esm-bundler.js:155
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:164
invoker
@ runtime-dom.esm-bundler.js:339
Promise.catch (async)
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:166
invoker
@ runtime-dom.esm-bundler.js:339