Merge branch 'main' of https://git.sun.museum/sam/parchment.page
This commit is contained in:
@@ -37,8 +37,8 @@ class Server {
|
|||||||
/* Site */
|
/* Site */
|
||||||
router.post('/free', this.newUserSubmission)
|
router.post('/free', this.newUserSubmission)
|
||||||
router.get('/db/images/*', this.getUserImage)
|
router.get('/db/images/*', this.getUserImage)
|
||||||
router.get('/app/orgdata/*', this.getOrgData)
|
router.get('/api/orgdata/*', this.getOrgData)
|
||||||
router.get('/app/mydata/*', this.getPersonalData)
|
router.get('/api/mydata/*', this.getPersonalData)
|
||||||
router.get('/*', this.get)
|
router.get('/*', this.get)
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,30 @@ class Server {
|
|||||||
this.auth = new AuthHandler()
|
this.auth = new AuthHandler()
|
||||||
const app = express();
|
const app = express();
|
||||||
app.post("/webhook", express.raw({ type: "application/json" }), PaymentsHandler.webhook)
|
app.post("/webhook", express.raw({ type: "application/json" }), PaymentsHandler.webhook)
|
||||||
app.use(cors({ origin: '*' }));
|
const allowedOrigins = new Set([
|
||||||
|
"https://www.parchment.page",
|
||||||
|
"https://parchment.page",
|
||||||
|
"http://localhost:5174",
|
||||||
|
"http://sam.local:5174",
|
||||||
|
"http://localhost:5173",
|
||||||
|
"http://sam.local:5173",
|
||||||
|
"http://localhost:10002",
|
||||||
|
"http://sam.local:10002",
|
||||||
|
"capacitor://localhost",
|
||||||
|
"http://localhost"
|
||||||
|
]);
|
||||||
|
app.use(cors({
|
||||||
|
origin(origin, cb) {
|
||||||
|
if (!origin) return cb(null, true); // native / curl
|
||||||
|
|
||||||
|
if (allowedOrigins.has(origin)) {
|
||||||
|
return cb(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cb(new Error("Blocked by CORS"));
|
||||||
|
},
|
||||||
|
credentials: true
|
||||||
|
}));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ let Global = class {
|
|||||||
|
|
||||||
async fetchAppData() {
|
async fetchAppData() {
|
||||||
let personalSpace = this.currentNetwork === this.profile
|
let personalSpace = this.currentNetwork === this.profile
|
||||||
let appData = await fetch(`/app/${personalSpace ? "my" : "org"}data/` + this.currentNetwork.id, {method: "GET"})
|
let appData = await fetch(`/api/${personalSpace ? "my" : "org"}data/` + this.currentNetwork.id, {method: "GET"})
|
||||||
let json = await appData.json()
|
let json = await appData.json()
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ async function openNetworkAndApp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!global.currentNetwork.data) {
|
if(!global.currentNetwork.data) {
|
||||||
let appData = await fetch("/app/orgdata/" + global.profile.networks[0].id, {method: "GET"})
|
let appData = await fetch("/api/orgdata/" + global.profile.networks[0].id, {method: "GET"})
|
||||||
let json = await appData.json()
|
let json = await appData.json()
|
||||||
global.currentNetwork.data = json
|
global.currentNetwork.data = json
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user