Añadido el modo producción / test
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { withAuth, getSessionCredentials } from "../../auth/index.js";
|
||||
import { getSessionCredentials } from "../../auth/index.js";
|
||||
import { handleToolError } from "../helpers/errorHandler.js";
|
||||
import { withAuthParams } from "../helpers/authSchema.js";
|
||||
|
||||
@@ -9,9 +9,10 @@ export function registerGetWebUrlTool(server) {
|
||||
`Get the correct URL for the project's development website. Always use this URL for fetch, Playwright, or any HTTP request to the site. Never guess or use production domains.`,
|
||||
withAuthParams({}),
|
||||
{ readOnlyHint: true, destructiveHint: false },
|
||||
withAuth(async (_params, extra) => {
|
||||
async (_params, extra) => {
|
||||
try {
|
||||
const credentials = await getSessionCredentials(extra.sessionId);
|
||||
const sessionId = extra?.sessionId || "_default";
|
||||
const credentials = await getSessionCredentials(sessionId);
|
||||
|
||||
if (!credentials || !credentials.web_url) {
|
||||
return {
|
||||
@@ -20,17 +21,11 @@ export function registerGetWebUrlTool(server) {
|
||||
};
|
||||
}
|
||||
|
||||
// Inside Docker, HTTPS is not available — force HTTP for internal requests
|
||||
let webUrl = credentials.web_url;
|
||||
if (webUrl && webUrl.startsWith("https://") && webUrl.includes(".forge.")) {
|
||||
webUrl = webUrl.replace("https://", "http://");
|
||||
}
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
text: JSON.stringify({
|
||||
web_url: webUrl,
|
||||
web_url: credentials.web_url,
|
||||
api_web_url: credentials.api_web_url || null,
|
||||
website: credentials.website || null,
|
||||
note: "Always use web_url for Playwright/fetch. IMPORTANT: Always append ?pruebas=1 to any URL you visit (e.g. web_url + '/?pruebas=1' or web_url + '/servicios/?pruebas=1'). Never use the production domain directly.",
|
||||
@@ -40,6 +35,6 @@ export function registerGetWebUrlTool(server) {
|
||||
} catch (error) {
|
||||
return handleToolError(error, "get_web_url", {});
|
||||
}
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user