mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	Report cache fix (#9447)
* Adjust allowed CORS headers * Disable caching in template preview
This commit is contained in:
		@@ -21,6 +21,7 @@ from django.core.validators import URLValidator
 | 
			
		||||
from django.http import Http404, HttpResponseGone
 | 
			
		||||
 | 
			
		||||
import structlog
 | 
			
		||||
from corsheaders.defaults import default_headers as default_cors_headers
 | 
			
		||||
from dotenv import load_dotenv
 | 
			
		||||
 | 
			
		||||
from InvenTree.cache import get_cache_config, is_global_cache_enabled
 | 
			
		||||
@@ -1203,6 +1204,11 @@ CORS_ALLOWED_ORIGIN_REGEXES = get_setting(
 | 
			
		||||
    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
 | 
			
		||||
# This allows connection from the frontend development server
 | 
			
		||||
if DEBUG:
 | 
			
		||||
 
 | 
			
		||||
@@ -131,8 +131,17 @@ export function TemplateEditor(props: Readonly<TemplateEditorProps>) {
 | 
			
		||||
 | 
			
		||||
    api.get(templateUrl).then((response: any) => {
 | 
			
		||||
      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
 | 
			
		||||
          .get(response.data.template)
 | 
			
		||||
          .get(response.data.template, {
 | 
			
		||||
            headers: {
 | 
			
		||||
              'Cache-Control': 'no-cache',
 | 
			
		||||
              Pragma: 'no-cache',
 | 
			
		||||
              Expires: '0'
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
          .then((res) => {
 | 
			
		||||
            codeRef.current = res.data;
 | 
			
		||||
            loadCodeToEditor(res.data);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user