Skip to content

Commit

Permalink
Merge pull request #1899 from ToshY/issue/1897
Browse files Browse the repository at this point in the history
fix(docker): add environment variable for puppeteer to launch with `ignoreHTTPSerrors` flag
  • Loading branch information
AmruthPillai committed May 15, 2024
2 parents 7a8b5d0 + f60fc63 commit a598a7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ REFRESH_TOKEN_SECRET=refresh_token_secret
CHROME_PORT=8080
CHROME_TOKEN=chrome_token
CHROME_URL=ws://localhost:8080
# Launch puppeteer with flag to ignore https errors
# CHROME_IGNORE_HTTPS_ERRORS=true

# Mail Server (for e-mails)
# For testing, you can use https://ethereal.email/create
Expand Down
4 changes: 4 additions & 0 deletions apps/server/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const configSchema = z.object({
// Browser
CHROME_TOKEN: z.string(),
CHROME_URL: z.string().url(),
CHROME_IGNORE_HTTPS_ERRORS: z
.string()
.default("false")
.transform((s) => s !== "false" && s !== "0"),

// Mail Server
MAIL_FROM: z.string().includes("@").optional().default("noreply@localhost"),
Expand Down
8 changes: 7 additions & 1 deletion apps/server/src/printer/printer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class PrinterService {

private readonly browserURL: string;

private readonly ignoreHTTPSErrors: boolean;

constructor(
private readonly configService: ConfigService<Config>,
private readonly storageService: StorageService,
Expand All @@ -26,11 +28,15 @@ export class PrinterService {
const chromeToken = this.configService.getOrThrow<string>("CHROME_TOKEN");

this.browserURL = `${chromeUrl}?token=${chromeToken}`;
this.ignoreHTTPSErrors = this.configService.getOrThrow<boolean>("CHROME_IGNORE_HTTPS_ERRORS");
}

private async getBrowser() {
try {
return await connect({ browserWSEndpoint: this.browserURL });
return await connect({
browserWSEndpoint: this.browserURL,
ignoreHTTPSErrors: this.ignoreHTTPSErrors,
});
} catch (error) {
throw new InternalServerErrorException(
ErrorMessage.InvalidBrowserConnection,
Expand Down

0 comments on commit a598a7a

Please sign in to comment.