mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-02 23:28:39 +08:00
sync: cross origin + small gui updates
This commit is contained in:
parent
783cf57934
commit
e60632343b
@ -368,7 +368,6 @@ class WebServerService extends BaseService {
|
|||||||
const ua_header = req.headers['user-agent'];
|
const ua_header = req.headers['user-agent'];
|
||||||
const ua = uaParser(ua_header);
|
const ua = uaParser(ua_header);
|
||||||
req.ua = ua;
|
req.ua = ua;
|
||||||
console.log('\x1B[26;1m===== UA =====\x1B[0m', ua);
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -382,10 +381,19 @@ class WebServerService extends BaseService {
|
|||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
const origin = req.headers.origin;
|
const origin = req.headers.origin;
|
||||||
|
|
||||||
const is_site = req.hostname.endsWith(config.static_hosting_domain);
|
const is_site =
|
||||||
|
req.hostname.endsWith(config.static_hosting_domain) ||
|
||||||
|
req.hostname === 'docs.puter.com'
|
||||||
|
;
|
||||||
const is_popup = !! req.query.embedded_in_popup;
|
const is_popup = !! req.query.embedded_in_popup;
|
||||||
|
const is_parent_co = !! req.query.cross_origin_isolated;
|
||||||
|
const is_app = !! req.query['puter.app_instance_id'];
|
||||||
|
|
||||||
const co_isolation_okay = !is_popup && (is_site || req.co_isolation_enabled);
|
const co_isolation_okay =
|
||||||
|
(!is_popup || is_parent_co) &&
|
||||||
|
(is_app || !is_site) &&
|
||||||
|
req.co_isolation_enabled
|
||||||
|
;
|
||||||
|
|
||||||
if ( req.path === '/signup' || req.path === '/login' ) {
|
if ( req.path === '/signup' || req.path === '/login' ) {
|
||||||
res.setHeader('Access-Control-Allow-Origin', origin ?? '*');
|
res.setHeader('Access-Control-Allow-Origin', origin ?? '*');
|
||||||
|
@ -497,6 +497,11 @@ window.addEventListener('message', async (event) => {
|
|||||||
if(!window.menubars[event.data.appInstanceID])
|
if(!window.menubars[event.data.appInstanceID])
|
||||||
window.menubars[event.data.appInstanceID] = value.items;
|
window.menubars[event.data.appInstanceID] = value.items;
|
||||||
|
|
||||||
|
// disable system context menu
|
||||||
|
$menubar.on('contextmenu', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
const sanitize_items = items => {
|
const sanitize_items = items => {
|
||||||
return items.map(item => {
|
return items.map(item => {
|
||||||
// Check if the item is just '-'
|
// Check if the item is just '-'
|
||||||
|
@ -468,7 +468,7 @@ class UI extends EventListener {
|
|||||||
let fpath = URLParams.get('puter.item.path');
|
let fpath = URLParams.get('puter.item.path');
|
||||||
|
|
||||||
if(!fpath.startsWith('~/') && !fpath.startsWith('/'))
|
if(!fpath.startsWith('~/') && !fpath.startsWith('/'))
|
||||||
fpath = '~/' + fpath
|
fpath = '~/' + fpath;
|
||||||
|
|
||||||
callback([new FSItem({
|
callback([new FSItem({
|
||||||
name: URLParams.get('puter.item.name'),
|
name: URLParams.get('puter.item.name'),
|
||||||
|
Loading…
Reference in New Issue
Block a user