Closed thebetterjort closed 7 years ago
When connecting to https://localhost:9000 I get this from firefox.
Secure Connection Failed
The connection to localhost:9000 was interrupted while the page was loading.
The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem.
I have a self-signed cert for my corporation. How can I disable such checks?
By default, this service refuses to work without https. In local development, you need to have ALLOW_HTTP=true
environment variable set when launching the server. By following install instructions here: https://github.com/alvarcarto/url-to-pdf-api#2-local-development the environment variable should appear to your local shell via the .env file.
You can also force the env variable in the command: ALLOW_HTTP=true npm start
Trying to dockeritize this project. The env aren't being honored. Any ideas?
FROM node:alpine
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm set strict-ssl false
RUN npm install
# Bundle app source
COPY . /usr/src/app
RUN source .env
EXPOSE 9000
CMD ["npm", "run", "start"]
.env
export NODE_ENV=development
export PORT=9000
export ALLOW_HTTP=true
I resolved this by passing ALLOW_HTTP=true in package.json
17-10-05T16:40:38.809Z - info: [app.js] ALLOW_HTTP=true, unsafe requests are allowed. Don't use this in production.
2017-10-05T16:40:38.810Z - info: [app.js] Using CORS options: origin=undefined, methods=[GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH]
2017-10-05T16:40:38.811Z - warn: [router.js] Warning: no authentication required to use the API
2017-10-05T16:40:38.816Z - info: [index.js] Express server listening on http://localhost:9000/ in development mode
2017-10-05T16:41:07.976Z - info: [pdf-core.js] Rendering with opts: {
"scrollPage": false,
"emulateScreenMedia": true,
"viewport": {
"width": 1600,
"height": 1200
},
"goto": {
"waitUntil": "networkidle",
"networkIdleTimeout": 2000
},
"pdf": {
"format": "A4",
"printBackground": true
},
"url": "http://google.com"
}
events.js:182
throw er; // Unhandled 'error' event
^
Error: spawn /usr/src/app/node_modules/puppeteer/.local-chromium/linux-499413/chrome-linux/chrome ENOENT
at _errnoException (util.js:1019:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
at onErrorNT (internal/child_process.js:374:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
[nodemon] app crashed - waiting for file changes before starting...
https://github.com/GoogleChrome/puppeteer/issues/379
Seems to be related to Docker and Chromium and not your package. Many thanks for your work.
docker run -e ALLOW_HTTP=true -p 9000:9000 anthonylau/url-to-pdf-api
http://localhost:9000/api/render?url=http://google.com