This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from eukarya-inc/add-auto-ogtag
Support auto fetch og tag
- Loading branch information
Showing
18 changed files
with
2,673 additions
and
1,033 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules/ | |
express-* | ||
notion-proxy | ||
gcp/ | ||
coverage/* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM node:18-slim | ||
|
||
# See: https://github.com/puppeteer/puppeteer/tree/main/docker | ||
# Install chrome on amd64 | ||
RUN apt-get update \ | ||
&& apt-get install -y wget gnupg python3 make g++ ca-certificates \ | ||
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg \ | ||
&& sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ | ||
&& apt-get update \ | ||
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 \ | ||
--no-install-recommends \ | ||
&& npm install -g pkg \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& groupadd -r pptruser && useradd -rm -g pptruser -G audio,video pptruser | ||
|
||
USER pptruser | ||
|
||
WORKDIR /notion-proxy | ||
COPY package*.json ./ | ||
COPY src ./src | ||
|
||
RUN npm ci | ||
RUN pkg src/expressApp.js -o /notion-proxy/app | ||
|
||
CMD ["/notion-proxy/app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,46 @@ | ||
## Notion proxy | ||
# Notion proxy | ||
|
||
Deliver notion pages via your domain. | ||
Reference [fruitionsite](https://github.com/stephenou/fruitionsite) for rewrite html processing. | ||
This proxy does not depend on Cloudflare and launches on express server. | ||
|
||
### Node Version | ||
## Node Version | ||
|
||
18 | ||
`<20.5.1` | ||
|
||
### Environment variable | ||
If using version 21.x or above, it will generate a deprecation warning indicating the use of the deprecated punycode module. | ||
|
||
| Env | Description | Default | | ||
|-------------------|--------------------------------------------|----------------------------------| | ||
| PAGE_TITLE | Page title on meta tag | "" | | ||
| PAGE_DESC | Page desc on meta tag | "" | | ||
| GOOGLE_FONT | See: `https://developers.google.com/fonts` | "" | | ||
| PROXY_PORT | Proxy port number | 3456 | | ||
| DOMAIN | Proxy domain for rewrite | localhost:3456 | | ||
| IS_TLS | Proxy tls(http/https) for rewrite | false | | ||
| NOTION_PAGE_ID | Notion public page id | f1db0cfbe246475784c67f279289abea | | ||
| CUSTOM_SCRIPT | Custom script | "" | | ||
| CONTENT_CACHE_SEC | Cache time for loaded content (sec) | 300 | | ||
## Environment variable | ||
|
||
### Getting started | ||
| ProxyConfig | Description | Default | | ||
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------| | ||
| PROXY_PORT | Proxy port number | "3456" | | ||
| DOMAIN | Proxy domain for rewrite | "localhost:3456" | | ||
| IS_TLS | Proxy tls(http/https) for rewrite | "false" | | ||
| NOTION_PAGE_ID | Notion public page id | "f1db0cfbe246475784c67f279289abea" | | ||
| CUSTOM_SCRIPT | Custom script | "" | | ||
| CONTENT_CACHE_SEC | Cache time for loaded content (sec) | "300" | | ||
| GOOGLE_FONT | See: `https://developers.google.com/fonts` | "" | | ||
| AUTO_SET_OGP | The server automatically extracts Open Graph Protocol (OGP) data from your NotionId upon startup. <br/>When this feature is enabled, the values of `OG_TAG_TITLE` and `OG_TAG_IMAGE_URL` are utilized for automatic configuration.<br/>If you prefer to wait until the OGP tags are fetched automatically, you can use the `/readyz` command.<br/><br/>Requirements<br/>- Headless chrome<br/>- CPU is always allocated<br/>- At least 512MB of memory for better | "false" | | ||
| OG_TAG_TITLE | Title for og tag | "" | | ||
| OG_TAG_DESC | Description for og tag | "" | | ||
| OG_TAG_IMAGE_URL | Image url for og tag | "" | | ||
| OG_TAG_TYPE | Type for og tag | "website" | | ||
| TWITTER_CARD | Twitter card for og tag | "summary_large_image" | | ||
|
||
### Note for AUTO_SET_OGP variable | ||
|
||
**OgTag setting priority** | ||
|
||
Environment variables with OG_xxx in prefix are set with the highest priority. | ||
So, if AUTO_SET_OGP is enabled but the OG_xxx environment variable is set, OG_xxx will have priority. | ||
|
||
**Headless chrome Requirements** | ||
|
||
At startup, we are extracting og tags from the NotionId page using Chrome Headless. | ||
So, CPU allocation is necessary. Please be cautious when using request allocation in services like Cloud Functions or Cloud Run or Other. | ||
|
||
## Getting started | ||
|
||
Start proxy for debug on local. | ||
|
||
|
@@ -32,7 +50,7 @@ $ npm test | |
$ npm start_proxy | ||
> [email protected] start | ||
> node src/index.js | ||
NotionProxy listening at localhost:3456, NotionId: f1db0cfbe246475784c67f279289abea | ||
Proxy listening at localhost:3456, NotionId: f1db0cfbe246475784c67f279289abea | ||
``` | ||
|
||
Start proxy binary. | ||
|
@@ -41,5 +59,5 @@ Start proxy binary. | |
$ npm install -g pkg | ||
$ npm run build | ||
$ ./notion-proxy | ||
NotionProxy listening at localhost:3456, NotionId: f1db0cfbe246475784c67f279289abea | ||
Proxy listening at localhost:3456, NotionId: f1db0cfbe246475784c67f279289abea | ||
``` |
Oops, something went wrong.