fix couchdb configs
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
FROM couchdb:latest
|
FROM couchdb:latest
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=5 CMD curl --fail http://localhost:5984 || exit 1
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=5 CMD curl --fail http://localhost:5984 || exit 1
|
||||||
COPY ./config/* /opt/couchdb/etc/local.d/*
|
COPY ./config/* /opt/couchdb/etc/local.d/
|
||||||
@@ -79,41 +79,6 @@ 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 () => {
|
export const down = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user