@automattic/mcp-wordpress-remote 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/proxy.js +6 -1
- package/package.json +1 -1
package/dist/proxy.js
CHANGED
|
@@ -1945,8 +1945,11 @@ function constructApiUrl(baseUrl, defaultEndpoint) {
|
|
|
1945
1945
|
try {
|
|
1946
1946
|
const urlObj = new URL(cleanUrl);
|
|
1947
1947
|
const hasCustomPath = urlObj.pathname && urlObj.pathname !== "/" && urlObj.pathname.length > 0;
|
|
1948
|
+
const isWordPressComPublicApi = urlObj.hostname === "public-api.wordpress.com";
|
|
1948
1949
|
if (hasCustomPath) {
|
|
1949
1950
|
return cleanUrl;
|
|
1951
|
+
} else if (isWordPressComPublicApi) {
|
|
1952
|
+
return new URL(defaultEndpoint, cleanUrl).toString();
|
|
1950
1953
|
} else {
|
|
1951
1954
|
return new URL(`/?rest_route=${defaultEndpoint}`, cleanUrl).toString();
|
|
1952
1955
|
}
|
|
@@ -2041,7 +2044,7 @@ async function getOAuthTokens() {
|
|
|
2041
2044
|
}
|
|
2042
2045
|
async function wpRequest(params = { method: "init" }) {
|
|
2043
2046
|
validateEnvironment();
|
|
2044
|
-
const endpoint = "/
|
|
2047
|
+
const endpoint = "/wpcom/v2/mcp/v1";
|
|
2045
2048
|
const method = "POST";
|
|
2046
2049
|
logger.api(`Request method: ${params.method || "init"}`);
|
|
2047
2050
|
logger.debug(`Request args: ${JSON.stringify(params.args || {})}`, "API");
|
|
@@ -2106,6 +2109,8 @@ async function wpRequest(params = { method: "init" }) {
|
|
|
2106
2109
|
};
|
|
2107
2110
|
try {
|
|
2108
2111
|
logger.api("Sending request to WordPress API...");
|
|
2112
|
+
logger.debug(`Request URL: ${url}`, "API");
|
|
2113
|
+
logger.debug(`Request method: ${method}`, "API");
|
|
2109
2114
|
const response = await fetch(url, fetchOptions);
|
|
2110
2115
|
logger.debug(`Response status: ${response.status}`, "API");
|
|
2111
2116
|
if (!response.ok) {
|