Updated config and OPTIONS method for function.
This commit is contained in:
parent
fd93444ac4
commit
606a51c767
@ -8,12 +8,13 @@ const authToken = Buffer.from(auth).toString('base64');
|
||||
function buildOptions(req: Request) {
|
||||
if (req.method == 'OPTIONS') {
|
||||
const origin = req.headers['origin'];
|
||||
console.log(origin);
|
||||
return new Response(
|
||||
"",
|
||||
{
|
||||
headers: {
|
||||
'Allow': 'POST',
|
||||
'Max-Age': '86400',
|
||||
'Max-Age': '30',
|
||||
'Access-Control-Allow-Methods': 'POST',
|
||||
'Access-Control-Allow-Origin': origin ? origin : 'https://cameras.immersiveidea.com',
|
||||
'Access-Control-Allow-Credentials': 'true'
|
||||
@ -147,7 +148,8 @@ export default async (req: Request, context: Context) => {
|
||||
console.log(req.method);
|
||||
|
||||
const options = buildOptions(req);
|
||||
if (options) {
|
||||
if (options != null) {
|
||||
console.log('Options Call Found');
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
@ -58,6 +58,7 @@ export class App {
|
||||
const diagramManager = new DiagramManager(scene, controllers, toolbox, config);
|
||||
|
||||
const db = new PouchdbPersistenceManager();
|
||||
db.setDiagramManager(diagramManager);
|
||||
db.configObserver.add((newConfig) => {
|
||||
config.onConfigChangedObservable.notifyObservers(newConfig, 1);
|
||||
});
|
||||
@ -65,6 +66,7 @@ export class App {
|
||||
db.setConfig(newConfig);
|
||||
}, 2, false, this);
|
||||
|
||||
|
||||
await db.initialize();
|
||||
|
||||
const environment = new CustomEnvironment(scene, "default", config);
|
||||
|
||||
@ -166,11 +166,11 @@ export class PouchdbPersistenceManager implements IPersistenceManager {
|
||||
const config = await this.config.get('1');
|
||||
if (config.currentDiagramId) {
|
||||
this.db = new PouchDB(config.currentDiagramId);
|
||||
await this.beginSync();
|
||||
await this.beginSync(config.currentDiagramId);
|
||||
} else {
|
||||
config.currentDiagramId = uuidv4();
|
||||
this.db = new PouchDB(config.currentDiagramId);
|
||||
await this.beginSync();
|
||||
await this.beginSync(config.currentDiagramId);
|
||||
await this.config.put(config);
|
||||
}
|
||||
this.configObserver.notifyObservers(config);
|
||||
@ -193,7 +193,7 @@ export class PouchdbPersistenceManager implements IPersistenceManager {
|
||||
|
||||
this.diagramListings.put({_id: defaultConfig.currentDiagramId, name: "New Diagram"});
|
||||
this.db = new PouchDB(defaultConfig.currentDiagramId);
|
||||
await this.beginSync();
|
||||
await this.beginSync(defaultConfig.currentDiagramId);
|
||||
this.configObserver.notifyObservers(defaultConfig);
|
||||
}
|
||||
try {
|
||||
@ -242,10 +242,10 @@ export class PouchdbPersistenceManager implements IPersistenceManager {
|
||||
|
||||
}
|
||||
|
||||
private async beginSync() {
|
||||
private async beginSync(remoteDbName: string) {
|
||||
try {
|
||||
|
||||
const remoteDbName = "db1";
|
||||
//const remoteDbName = "db1";
|
||||
const remoteUserName = "user1";
|
||||
const password = "password";
|
||||
const dbs = await axios.get(import.meta.env.VITE_SYNCDB_ENDPOINT + '_all_dbs');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user