Compare commits
No commits in common. "main" and "fix/login-issue" have entirely different histories.
main
...
fix/login-
4 changed files with 13 additions and 39 deletions
|
|
@ -17,7 +17,6 @@ import {
|
|||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import { PresentationGenerationApi } from "../../services/api/presentation-generation";
|
||||
import { apiFetch, apiUrl } from "@/lib/apiFetch";
|
||||
import { OverlayLoader } from "@/components/ui/overlay-loader";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
|
|
@ -60,7 +59,7 @@ const Header = ({
|
|||
const { onUndo, onRedo, canUndo, canRedo } = usePresentationUndoRedo();
|
||||
|
||||
const get_presentation_pptx_model = async (id: string): Promise<PptxPresentationModel> => {
|
||||
const response = await apiFetch(`/api/presentation_to_pptx_model?id=${id}`);
|
||||
const response = await fetch(`/api/presentation_to_pptx_model?id=${id}`);
|
||||
const pptx_model = await response.json();
|
||||
return pptx_model;
|
||||
};
|
||||
|
|
@ -105,7 +104,7 @@ const Header = ({
|
|||
// Save the presentation data before exporting
|
||||
await PresentationGenerationApi.updatePresentationContent(presentationData);
|
||||
|
||||
const response = await apiFetch('/api/export-as-pdf', {
|
||||
const response = await fetch('/api/export-as-pdf', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
id: presentation_id,
|
||||
|
|
@ -137,14 +136,13 @@ const Header = ({
|
|||
router.push(`/presentation?id=${presentation_id}&stream=true`);
|
||||
};
|
||||
const downloadLink = (path: string) => {
|
||||
const url = apiUrl(path);
|
||||
// if we have popup access give direct download if not redirect to the path
|
||||
if (window.opener) {
|
||||
window.open(url, '_blank');
|
||||
window.open(path, '_blank');
|
||||
} else {
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = url.split('/').pop() || 'download';
|
||||
link.href = path;
|
||||
link.download = path.split('/').pop() || 'download';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ export async function GET(request: NextRequest) {
|
|||
|
||||
try {
|
||||
const id = await getPresentationId(request);
|
||||
const sessionToken = request.cookies.get("session_token")?.value;
|
||||
[browser, page] = await getBrowserAndPage(id, sessionToken);
|
||||
[browser, page] = await getBrowserAndPage(id);
|
||||
const screenshotsDir = getScreenshotsDir();
|
||||
|
||||
const { slides, speakerNotes } = await getSlidesAndSpeakerNotes(page);
|
||||
|
|
@ -76,10 +75,7 @@ async function getPresentationId(request: NextRequest) {
|
|||
return id;
|
||||
}
|
||||
|
||||
async function getBrowserAndPage(
|
||||
id: string,
|
||||
sessionToken: string | undefined
|
||||
): Promise<[Browser, Page]> {
|
||||
async function getBrowserAndPage(id: string): Promise<[Browser, Page]> {
|
||||
const browser = await puppeteer.launch({
|
||||
executablePath: process.env.PUPPETEER_EXECUTABLE_PATH,
|
||||
headless: true,
|
||||
|
|
@ -103,24 +99,10 @@ async function getBrowserAndPage(
|
|||
page.setDefaultNavigationTimeout(300000);
|
||||
page.setDefaultTimeout(300000);
|
||||
const baseUrl = process.env.PUPPETEER_BASE_URL || `http://localhost:${process.env.PORT || 3000}`;
|
||||
|
||||
if (sessionToken) {
|
||||
await page.setCookie({
|
||||
name: "session_token",
|
||||
value: sessionToken,
|
||||
url: baseUrl,
|
||||
httpOnly: true,
|
||||
});
|
||||
}
|
||||
|
||||
await page.goto(`${baseUrl}/ppt-tool/pdf-maker?id=${id}`, {
|
||||
waitUntil: "domcontentloaded",
|
||||
timeout: 60000,
|
||||
await page.goto(`${baseUrl}/pdf-maker?id=${id}`, {
|
||||
waitUntil: "networkidle0",
|
||||
timeout: 300000,
|
||||
});
|
||||
await page.waitForSelector(
|
||||
"#presentation-slides-wrapper [data-speaker-note]",
|
||||
{ timeout: 120000 }
|
||||
);
|
||||
return [browser, page];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,18 +7,12 @@
|
|||
*/
|
||||
const BASE_PATH = '/ppt-tool';
|
||||
|
||||
const PREFIXED_PATHS = ['/api/', '/app_data/', '/static/'];
|
||||
|
||||
function needsBasePath(path: string): boolean {
|
||||
return PREFIXED_PATHS.some((p) => path.startsWith(p));
|
||||
}
|
||||
|
||||
export function apiFetch(path: string, init?: RequestInit): Promise<Response> {
|
||||
const url = needsBasePath(path) ? `${BASE_PATH}${path}` : path;
|
||||
const url = path.startsWith('/api/') ? `${BASE_PATH}${path}` : path;
|
||||
return fetch(url, init);
|
||||
}
|
||||
|
||||
/** Returns the full URL with basePath — use for EventSource and other non-fetch calls. */
|
||||
export function apiUrl(path: string): string {
|
||||
return needsBasePath(path) ? `${BASE_PATH}${path}` : path;
|
||||
return path.startsWith('/api/') ? `${BASE_PATH}${path}` : path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ function convertToAutoShapeBox(element: ElementAttributes): PptxAutoShapeBoxMode
|
|||
shadow,
|
||||
position,
|
||||
text_wrap: element.textWrap ?? true,
|
||||
border_radius: borderRadius ? Math.round(borderRadius) : undefined,
|
||||
border_radius: borderRadius || undefined,
|
||||
paragraphs
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue