Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:8.7.0

WORKDIR /usr/src/app
ENV NODE_ENV production
ENV PORT 9000
EXPOSE 9000

RUN apt-get update \
&& apt-get install -yq \
gconf-service libasound2 libatk1.0-0 libc6 \
libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \
libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 \
libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 \
libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation \
libappindicator1 libnss3 lsb-release xdg-utils wget \
&& rm -r /var/lib/apt/lists/*

COPY package.json .

RUN npm install

COPY . .

CMD ["node", "src/index.js"]
6 changes: 6 additions & 0 deletions src/core/render-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ async function render(_opts = {}) {
await client.send('Network.setCookies', { cookies: opts.cookies });
}

if (opts.setExtraHTTPHeaders) {
logger.info('Set setExtraHTTPHeaders ..');
await page.setExtraHTTPHeaders(opts.setExtraHTTPHeaders);
}


if (opts.html) {
logger.info('Set HTML ..');
await page.setContent(opts.html, opts.goto);
Expand Down
1 change: 1 addition & 0 deletions src/http/render-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function getOptsFromQuery(query) {
},
omitBackground: query['screenshot.omitBackground'],
},
setExtraHTTPHeaders:query['setExtraHTTPHeaders'],
};
return opts;
}
Expand Down
2 changes: 2 additions & 0 deletions src/util/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const sharedQuerySchema = Joi.object({
'screenshot.clip.width': Joi.number(),
'screenshot.clip.height': Joi.number(),
'screenshot.omitBackground': Joi.boolean(),
'setExtraHTTPHeaders': Joi.object(),
});

const renderQuerySchema = Joi.object({
Expand Down Expand Up @@ -126,6 +127,7 @@ const renderBodyObject = Joi.object({
omitBackground: Joi.boolean(),
}),
failEarly: Joi.string(),
setExtraHTTPHeaders: Joi.object(),
});

const renderBodySchema = Joi.alternatives([
Expand Down