SOY NV AI
commited on
Commit
ยท
12d93bf
1
Parent(s):
a233557
Fix: Add Permissions-Policy header and replace autofocus with JavaScript to fix iframe warnings
Browse files- app/__init__.py +15 -0
- templates/login.html +20 -1
app/__init__.py
CHANGED
|
@@ -107,6 +107,21 @@ def create_app() -> Flask:
|
|
| 107 |
def log_response_info(response):
|
| 108 |
"""๊ฐ HTTP ์๋ต ์ ๋ณด๋ฅผ ๋ก๊น
"""
|
| 109 |
logger.info(f"[์๋ต] {request.method} {request.path} - ์ํ: {response.status_code}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
return response
|
| 111 |
|
| 112 |
# ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ด๊ธฐํ ๋ฐ ๋ง์ด๊ทธ๋ ์ด์
|
|
|
|
| 107 |
def log_response_info(response):
|
| 108 |
"""๊ฐ HTTP ์๋ต ์ ๋ณด๋ฅผ ๋ก๊น
"""
|
| 109 |
logger.info(f"[์๋ต] {request.method} {request.path} - ์ํ: {response.status_code}")
|
| 110 |
+
|
| 111 |
+
# Permissions-Policy ํค๋ ์ถ๊ฐ (iframe ์๋ฒ ๋ ์ ๊ฒฝ๊ณ ๋ฐฉ์ง)
|
| 112 |
+
# Hugging Face Spaces์์ iframe์ผ๋ก ์๋ฒ ๋๋ ๋ ๋ฐ์ํ๋ ๊ฒฝ๊ณ ๋ฅผ ๋ฐฉ์ง
|
| 113 |
+
permissions_policy = (
|
| 114 |
+
"ambient-light-sensor=(), "
|
| 115 |
+
"battery=(), "
|
| 116 |
+
"document-domain=(), "
|
| 117 |
+
"layout-animations=(), "
|
| 118 |
+
"legacy-image-formats=(), "
|
| 119 |
+
"oversized-images=(), "
|
| 120 |
+
"vr=(), "
|
| 121 |
+
"wake-lock=()"
|
| 122 |
+
)
|
| 123 |
+
response.headers['Permissions-Policy'] = permissions_policy
|
| 124 |
+
|
| 125 |
return response
|
| 126 |
|
| 127 |
# ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ด๊ธฐํ ๋ฐ ๋ง์ด๊ทธ๋ ์ด์
|
templates/login.html
CHANGED
|
@@ -155,7 +155,7 @@
|
|
| 155 |
<form method="POST" action="{{ url_for('main.login') }}">
|
| 156 |
<div class="form-group">
|
| 157 |
<label for="username">์ฌ์ฉ์๋ช
</label>
|
| 158 |
-
<input type="text" id="username" name="username" required
|
| 159 |
</div>
|
| 160 |
|
| 161 |
<div class="form-group">
|
|
@@ -166,6 +166,25 @@
|
|
| 166 |
<button type="submit" class="login-button">๋ก๊ทธ์ธ</button>
|
| 167 |
</form>
|
| 168 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
</body>
|
| 170 |
</html>
|
| 171 |
|
|
|
|
| 155 |
<form method="POST" action="{{ url_for('main.login') }}">
|
| 156 |
<div class="form-group">
|
| 157 |
<label for="username">์ฌ์ฉ์๋ช
</label>
|
| 158 |
+
<input type="text" id="username" name="username" required>
|
| 159 |
</div>
|
| 160 |
|
| 161 |
<div class="form-group">
|
|
|
|
| 166 |
<button type="submit" class="login-button">๋ก๊ทธ์ธ</button>
|
| 167 |
</form>
|
| 168 |
</div>
|
| 169 |
+
|
| 170 |
+
<script>
|
| 171 |
+
// iframe ๋ด๋ถ์์๋ ์๋ํ๋๋ก JavaScript๋ก autofocus ์ฒ๋ฆฌ
|
| 172 |
+
// Cross-origin iframe์์ autofocus๊ฐ ์ฐจ๋จ๋๋ ๋ฌธ์ ํด๊ฒฐ
|
| 173 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 174 |
+
const usernameInput = document.getElementById('username');
|
| 175 |
+
if (usernameInput) {
|
| 176 |
+
// ์ฝ๊ฐ์ ์ง์ฐ์ ๋์ด iframe ๋ก๋ฉ ์๋ฃ ํ ํฌ์ปค์ค
|
| 177 |
+
setTimeout(function() {
|
| 178 |
+
try {
|
| 179 |
+
usernameInput.focus();
|
| 180 |
+
} catch (e) {
|
| 181 |
+
// iframe์์ ํฌ์ปค์ค๊ฐ ์ฐจ๋จ๋ ์ ์์ผ๋ฏ๋ก ๋ฌด์
|
| 182 |
+
console.debug('Autofocus blocked in iframe (expected behavior)');
|
| 183 |
+
}
|
| 184 |
+
}, 100);
|
| 185 |
+
}
|
| 186 |
+
});
|
| 187 |
+
</script>
|
| 188 |
</body>
|
| 189 |
</html>
|
| 190 |
|