fix local build
Deploy app frontend / app frontend (push) Successful in 1m42s
Deploy service couchdb / service couchdb (push) Successful in 31s
Deploy db-migrations / db-migrations (push) Successful in 1m6s
Deploy service message-delivery-method-web-push / service message-delivery-method-web-push (push) Successful in 1m4s
Deploy app frontend / app frontend (push) Successful in 1m42s
Deploy service couchdb / service couchdb (push) Successful in 31s
Deploy db-migrations / db-migrations (push) Successful in 1m6s
Deploy service message-delivery-method-web-push / service message-delivery-method-web-push (push) Successful in 1m4s
This commit is contained in:
@@ -35,9 +35,10 @@ if (!process.env.API_URL) {
|
||||
throw new Error("Environment variable API_URL is not set");
|
||||
}
|
||||
const urlObject = new URL(process.env.API_URL);
|
||||
const auth = `${urlObject.username}:${urlObject.password}`;
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Basic " + btoa(`${urlObject.username}:${urlObject.password}`),
|
||||
Authorization: "Basic " + btoa(auth),
|
||||
};
|
||||
const getUrl = (dbUrlPath) => {
|
||||
return `${urlObject.protocol}//${urlObject.host}${urlObject.pathname}/${dbUrlPath}${urlObject.search}${urlObject.hash}`;
|
||||
@@ -78,6 +79,41 @@ export const up = async () => {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const corsConfig = {
|
||||
"chttpd/enable_cors": "true",
|
||||
"cors/origins": "*",
|
||||
"cors/credentials": "true",
|
||||
"cors/methods": "GET, PUT, POST, HEAD, DELETE",
|
||||
"cors/headers":
|
||||
"accept, authorization, content-type, origin, referer, x-csrf-token",
|
||||
};
|
||||
|
||||
const membership = await fetch(getUrl("_membership"), { headers }).then(
|
||||
(response) => response.json(),
|
||||
);
|
||||
if (!membership || membership.error) {
|
||||
throw new Error(`_membership error ${JSON.stringify(membership)}`);
|
||||
}
|
||||
|
||||
for (const node of membership.cluster_nodes) {
|
||||
for (const [configPath, value] of Object.entries(corsConfig)) {
|
||||
const corsURL = `_node/${node}/_config/${configPath}`;
|
||||
const response = await fetch(getUrl(corsURL), {
|
||||
method: "PUT",
|
||||
headers,
|
||||
body: JSON.stringify(value),
|
||||
}).then((response) => response.json());
|
||||
|
||||
if (!response.error) {
|
||||
console.log(`set ${configPath} ${response}`);
|
||||
} else {
|
||||
throw new Error(
|
||||
`${corsURL} set ${value} error ${JSON.stringify(response)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const down = async () => {
|
||||
|
||||
Reference in New Issue
Block a user