Enhance API access control and update Docker configuration
- Added port mapping to docker-compose for local development. - Modified the API to allow access from localhost without Telegram initData for local development. - Updated the web application to check for localhost before denying access based on initData.
This commit is contained in:
@@ -36,6 +36,11 @@
|
||||
return (window.Telegram && window.Telegram.WebApp && window.Telegram.WebApp.initData) || "";
|
||||
}
|
||||
|
||||
function isLocalhost() {
|
||||
var h = window.location.hostname;
|
||||
return h === "localhost" || h === "127.0.0.1" || h === "";
|
||||
}
|
||||
|
||||
function showAccessDenied() {
|
||||
if (headerEl) headerEl.hidden = true;
|
||||
if (weekdaysEl) weekdaysEl.hidden = true;
|
||||
@@ -147,7 +152,8 @@
|
||||
}
|
||||
|
||||
async function loadMonth() {
|
||||
if (!getInitData()) {
|
||||
var _initData = getInitData();
|
||||
if (!_initData && !isLocalhost()) {
|
||||
showAccessDenied();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user