Skip to content

Commit 0a390fa

Browse files
committed
web : Use query parameter to bust cached URLs. Clarify instructions.
1 parent 49590ef commit 0a390fa

File tree

14 files changed

+88
-26
lines changed

14 files changed

+88
-26
lines changed

authentik/api/templates/api/browser.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% endblock %}
88

99
{% block head %}
10-
<script src="{% versioned_script 'dist/standalone/api-browser/index-%v.js' %}" type="module"></script>
10+
<script src="{% versioned_script 'dist/standalone/api-browser/index.js' %}" type="module"></script>
1111
{% endblock %}
1212

1313
{% block body %}

authentik/core/templates/base/skeleton.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<link rel="stylesheet" type="text/css" href="{% static 'dist/authentik.css' %}">
2222

2323
<style>{{ brand_css }}</style>
24-
<script src="{% versioned_script 'dist/poly-%v.js' %}" type="module"></script>
25-
<script src="{% versioned_script 'dist/standalone/loading/index-%v.js' %}" type="module"></script>
24+
<script src="{% versioned_script 'dist/poly.js' %}" type="module"></script>
25+
<script src="{% versioned_script 'dist/standalone/loading/index.js' %}" type="module"></script>
2626
{% block head %}
2727
{% endblock %}
2828
{% for key, value in html_meta.items %}

authentik/core/templates/if/admin.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% load authentik_core %}
44

55
{% block head %}
6-
<script src="{% versioned_script 'dist/admin/AdminInterface-%v.js' %}" type="module"></script>
6+
<script src="{% versioned_script 'dist/admin/AdminInterface.js' %}" type="module"></script>
77
{% include "base/header_js.html" %}
88
{% endblock %}
99

authentik/core/templates/if/user.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% load authentik_core %}
44

55
{% block head %}
6-
<script src="{% versioned_script 'dist/user/UserInterface-%v.js' %}" type="module"></script>
6+
<script src="{% versioned_script 'dist/user/UserInterface.js' %}" type="module"></script>
77
{% include "base/header_js.html" %}
88
{% endblock %}
99

authentik/core/templatetags/authentik_core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from django import template
44
from django.templatetags.static import static as static_loader
5+
from django.utils.safestring import mark_safe
56

67
from authentik import authentik_full_version
78

@@ -10,5 +11,6 @@
1011

1112
@register.simple_tag()
1213
def versioned_script(path: str) -> str:
13-
"""Wrapper around {% static %} tag that supports setting the version"""
14-
return static_loader(path.replace("%v", authentik_full_version()))
14+
"""Wrapper around {% static %} tag that appends a version query parameter to the URL"""
15+
16+
return static_loader(path) + "?v=" + authentik_full_version()

authentik/flows/templates/if/flow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{% endblock %}
1919

2020
{% block head %}
21-
<script src="{% versioned_script 'dist/flow/FlowInterface-%v.js' %}" type="module"></script>
21+
<script src="{% versioned_script 'dist/flow/FlowInterface.js' %}" type="module"></script>
2222
<style>
2323
:root {
2424
--ak-flow-background: url("{{ flow_background_url }}");

authentik/providers/rac/templates/if/rac.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% load authentik_core %}
44

55
{% block head %}
6-
<script src="{% versioned_script 'dist/rac/index-%v.js' %}" type="module"></script>
6+
<script src="{% versioned_script 'dist/rac/index.js' %}" type="module"></script>
77
<link rel="icon" href="{{ tenant.branding_favicon_url }}">
88
<link rel="shortcut icon" href="{{ tenant.branding_favicon_url }}">
99
{% include "base/header_js.html" %}

web/bundler/utils/node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { NodeEnvironment, serializeEnvironmentVars } from "@goauthentik/core/environment/node";
6-
import { AuthentikVersion } from "@goauthentik/core/version/node";
6+
import { readAuthentikVersion } from "@goauthentik/core/version/node";
77

88
/**
99
* Creates a mapping of environment variables to their respective runtime constants.
@@ -17,7 +17,7 @@ export function createBundleDefinitions() {
1717
* @satisfies {Record<ESBuildImportEnvKey, string>}
1818
*/
1919
const envRecord = {
20-
AK_VERSION: AuthentikVersion,
20+
AK_VERSION: readAuthentikVersion(),
2121
AK_API_BASE_PATH: process.env.AK_API_BASE_PATH ?? "",
2222
};
2323

web/package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @file Load the contents of an environment file into `process.env`.
3+
*/
4+
import { MonoRepoRoot } from "#paths/node";
5+
import { existsSync } from "node:fs";
6+
import { join } from "node:path";
7+
8+
const envFilePath = join(MonoRepoRoot, ".env");
9+
10+
if (existsSync(envFilePath)) {
11+
console.debug(`Loading environment from ${envFilePath}`);
12+
13+
process.loadEnvFile(envFilePath);
14+
}

0 commit comments

Comments
 (0)