2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

Report cache fix (#9447) (#9448)

* Adjust allowed CORS headers

* Disable caching in template preview

(cherry picked from commit c4f98cd6a1fd0eecb7c702c6588b007395f2d001)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot] 2025-04-03 15:21:57 +11:00 committed by GitHub
parent 00470a844c
commit 2a9d737157
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -21,6 +21,7 @@ from django.http import Http404
import pytz import pytz
import structlog import structlog
from corsheaders.defaults import default_headers as default_cors_headers
from dotenv import load_dotenv from dotenv import load_dotenv
from InvenTree.cache import get_cache_config, is_global_cache_enabled from InvenTree.cache import get_cache_config, is_global_cache_enabled
@ -1290,6 +1291,11 @@ CORS_ALLOWED_ORIGIN_REGEXES = get_setting(
typecast=list, typecast=list,
) )
# Allow extra CORS headers in DEBUG mode
# Required for serving /static/ and /media/ files
if DEBUG:
CORS_ALLOW_HEADERS = (*default_cors_headers, 'cache-control', 'pragma', 'expires')
# In debug mode allow CORS requests from localhost # In debug mode allow CORS requests from localhost
# This allows connection from the frontend development server # This allows connection from the frontend development server
if DEBUG: if DEBUG:

View File

@ -132,8 +132,17 @@ export function TemplateEditor(props: Readonly<TemplateEditorProps>) {
api.get(templateUrl).then((response: any) => { api.get(templateUrl).then((response: any) => {
if (response.data?.template) { if (response.data?.template) {
// Fetch the raw template file from the server
// Request that it is provided without any caching,
// to ensure that we always get the latest version
api api
.get(response.data.template) .get(response.data.template, {
headers: {
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0'
}
})
.then((res) => { .then((res) => {
codeRef.current = res.data; codeRef.current = res.data;
loadCodeToEditor(res.data); loadCodeToEditor(res.data);