fix(printer): fix issue with printer service, locating the right URL of the server
This commit is contained in:
parent
4447b58b8f
commit
6255849822
|
@ -4,6 +4,7 @@ SECRET_KEY=change-me
|
||||||
|
|
||||||
# URLs
|
# URLs
|
||||||
PUBLIC_URL=http://localhost:3000
|
PUBLIC_URL=http://localhost:3000
|
||||||
|
PUBLIC_SERVER_URL=http://localhost:3100
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
POSTGRES_HOST=localhost
|
POSTGRES_HOST=localhost
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "attach",
|
||||||
|
"name": "Debug: Server",
|
||||||
|
"port": 9229,
|
||||||
|
"restart": true,
|
||||||
|
"stopOnEntry": false,
|
||||||
|
"protocol": "inspector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug: Client",
|
||||||
|
"type": "node-terminal",
|
||||||
|
"request": "launch",
|
||||||
|
"command": "pnpm run dev:client",
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"serverReadyAction": {
|
||||||
|
"pattern": "started server on .+, url: (https?://.+)",
|
||||||
|
"uriFormat": "%s",
|
||||||
|
"action": "debugWithChrome"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -116,7 +116,7 @@ Reactive Resume would be nothing without the folks who supported me and kept the
|
||||||
- DigitalOcean, infrastructure provider
|
- DigitalOcean, infrastructure provider
|
||||||
- Crowdin, translation management platform
|
- Crowdin, translation management platform
|
||||||
|
|
||||||
<a href="https://www.digitalocean.com/">
|
<a href="https://pillai.xyz/digitalocean">
|
||||||
<img src="https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/PoweredByDO/DO_Powered_by_Badge_blue.svg" width="200px" />
|
<img src="https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/PoweredByDO/DO_Powered_by_Badge_blue.svg" width="200px" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,14 @@ RUN apk add --no-cache curl \
|
||||||
|
|
||||||
COPY --from=builder /app/pnpm-*.yaml ./
|
COPY --from=builder /app/pnpm-*.yaml ./
|
||||||
COPY --from=builder /app/package.json ./
|
COPY --from=builder /app/package.json ./
|
||||||
|
COPY --from=builder /app/client/package.json ./client/package.json
|
||||||
|
|
||||||
|
RUN pnpm install -F client --frozen-lockfile --prod
|
||||||
|
|
||||||
COPY --from=builder /app/client/.next ./client/.next
|
COPY --from=builder /app/client/.next ./client/.next
|
||||||
COPY --from=builder /app/client/public ./client/public
|
COPY --from=builder /app/client/public ./client/public
|
||||||
COPY --from=builder /app/client/next.config.js ./client/next.config.js
|
COPY --from=builder /app/client/next.config.js ./client/next.config.js
|
||||||
COPY --from=builder /app/client/next-i18next.config.js ./client/next-i18next.config.js
|
COPY --from=builder /app/client/next-i18next.config.js ./client/next-i18next.config.js
|
||||||
COPY --from=builder /app/client/package.json ./client/package.json
|
|
||||||
|
|
||||||
RUN pnpm install -F client --frozen-lockfile --prod
|
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ const ArtboardController: React.FC<ReactZoomPanPinchRef> = ({ zoomIn, zoomOut, c
|
||||||
|
|
||||||
const url = await mutateAsync({ username, slug });
|
const url = await mutateAsync({ username, slug });
|
||||||
|
|
||||||
download(url);
|
download(`/api${url}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -47,7 +47,7 @@ const Export = () => {
|
||||||
|
|
||||||
const url = await mutateAsync({ username, slug });
|
const url = await mutateAsync({ username, slug });
|
||||||
|
|
||||||
download(url);
|
download(`/api${url}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -90,7 +90,7 @@ const Preview: NextPage<Props> = ({ username, slug, resume: initialData }) => {
|
||||||
try {
|
try {
|
||||||
const url = await mutateAsync({ username, slug });
|
const url = await mutateAsync({ username, slug });
|
||||||
|
|
||||||
download(url);
|
download(`/api${url}`);
|
||||||
} catch {
|
} catch {
|
||||||
toast.error('Something went wrong, please try again later.');
|
toast.error('Something went wrong, please try again later.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ const Home: NextPage = () => {
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className={styles.section}>
|
<section className={styles.section}>
|
||||||
<a href="https://www.digitalocean.com/" target="_blank" rel="noreferrer">
|
<a href="https://pillai.xyz/digitalocean" target="_blank" rel="noreferrer">
|
||||||
<Image src="/images/sponsors/digitalocean.svg" alt="Powered By DigitalOcean" width={200} height={40} />
|
<Image src="/images/sponsors/digitalocean.svg" alt="Powered By DigitalOcean" width={200} height={40} />
|
||||||
</a>
|
</a>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -60,7 +60,7 @@ const Preview: NextPage<Props> = ({ shortId }) => {
|
||||||
try {
|
try {
|
||||||
const url = await mutateAsync({ username: resume.user.username, slug: resume.slug });
|
const url = await mutateAsync({ username: resume.user.username, slug: resume.slug });
|
||||||
|
|
||||||
download(url);
|
download(`/api${url}`);
|
||||||
} catch {
|
} catch {
|
||||||
toast.error('Something went wrong, please try again later.');
|
toast.error('Something went wrong, please try again later.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import env from '@beam-australia/react-env';
|
||||||
import { Resume } from '@reactive-resume/schema';
|
import { Resume } from '@reactive-resume/schema';
|
||||||
import { AxiosResponse } from 'axios';
|
import _axios, { AxiosResponse } from 'axios';
|
||||||
import isEmpty from 'lodash/isEmpty';
|
|
||||||
|
|
||||||
import isBrowser from '@/utils/isBrowser';
|
import isBrowser from '@/utils/isBrowser';
|
||||||
|
|
||||||
|
@ -22,9 +22,6 @@ export type FetchResumeByIdentifierParams = {
|
||||||
|
|
||||||
export type FetchResumeByShortIdParams = {
|
export type FetchResumeByShortIdParams = {
|
||||||
shortId: string;
|
shortId: string;
|
||||||
options?: {
|
|
||||||
secretKey?: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RenameResumeParams = {
|
export type RenameResumeParams = {
|
||||||
|
@ -60,23 +57,26 @@ export type DeleteResumeParams = {
|
||||||
|
|
||||||
export const fetchResumes = () => axios.get<Resume[]>('/resume').then((res) => res.data);
|
export const fetchResumes = () => axios.get<Resume[]>('/resume').then((res) => res.data);
|
||||||
|
|
||||||
export const fetchResumeByShortId = async ({ shortId, options = { secretKey: '' } }: FetchResumeByShortIdParams) => {
|
|
||||||
const requestOptions = isEmpty(options.secretKey) ? {} : { params: { secretKey: options.secretKey } };
|
|
||||||
|
|
||||||
return axios.get<Resume>(`/resume/short/${shortId}`, requestOptions).then((res) => res.data);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fetchResumeByIdentifier = async ({
|
export const fetchResumeByIdentifier = async ({
|
||||||
username,
|
username,
|
||||||
slug,
|
slug,
|
||||||
options = { secretKey: '' },
|
options = { secretKey: '' },
|
||||||
}: FetchResumeByIdentifierParams) => {
|
}: FetchResumeByIdentifierParams) => {
|
||||||
const prefix = !isBrowser && process.env.NODE_ENV === 'development' ? 'http://localhost:3100' : '';
|
if (!isBrowser) {
|
||||||
const requestOptions = isEmpty(options.secretKey) ? {} : { params: { secretKey: options.secretKey } };
|
const serverUrl = env('SERVER_URL');
|
||||||
|
const secretKey = options.secretKey;
|
||||||
|
|
||||||
return axios.get<Resume>(`${prefix}/resume/${username}/${slug}`, requestOptions).then((res) => res.data);
|
return _axios
|
||||||
|
.get<Resume>(`${serverUrl}/resume/${username}/${slug}`, { params: { secretKey } })
|
||||||
|
.then((res) => res.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return axios.get<Resume>(`/resume/${username}/${slug}`).then((res) => res.data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const fetchResumeByShortId = async ({ shortId }: FetchResumeByShortIdParams) =>
|
||||||
|
axios.get<Resume>(`/resume/short/${shortId}`).then((res) => res.data);
|
||||||
|
|
||||||
export const createResume = (createResumeParams: CreateResumeParams) =>
|
export const createResume = (createResumeParams: CreateResumeParams) =>
|
||||||
axios.post<Resume, AxiosResponse<Resume>, CreateResumeParams>('/resume', createResumeParams).then((res) => res.data);
|
axios.post<Resume, AxiosResponse<Resume>, CreateResumeParams>('/resume', createResumeParams).then((res) => res.data);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ services:
|
||||||
container_name: server
|
container_name: server
|
||||||
env_file: .env
|
env_file: .env
|
||||||
environment:
|
environment:
|
||||||
|
- PUBLIC_URL=http://client:3000
|
||||||
- POSTGRES_HOST=postgres
|
- POSTGRES_HOST=postgres
|
||||||
ports:
|
ports:
|
||||||
- 3100:3100
|
- 3100:3100
|
||||||
|
@ -38,6 +39,8 @@ services:
|
||||||
dockerfile: client/Dockerfile
|
dockerfile: client/Dockerfile
|
||||||
container_name: client
|
container_name: client
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
- PUBLIC_SERVER_URL=http://server:3100
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"lint": "eslint --fix --ext .js,.ts,.tsx .",
|
"lint": "eslint --fix --ext .js,.ts,.tsx .",
|
||||||
"format": "prettier --write \"./**/*.{js,ts,tsx,json}\"",
|
"format": "prettier --write \"./**/*.{js,ts,tsx,json}\"",
|
||||||
"dev:schema": "pnpm -F schema dev",
|
"dev:schema": "pnpm -F schema dev",
|
||||||
"dev:server": "pnpm -F server start:dev",
|
"dev:server": "pnpm -F server start:debugc",
|
||||||
"dev:client": "pnpm -F client dev",
|
"dev:client": "pnpm -F client dev",
|
||||||
"dev": "env-cmd --silent concurrently --kill-others \"pnpm run dev:*\"",
|
"dev": "env-cmd --silent concurrently --kill-others \"pnpm run dev:*\"",
|
||||||
"build:schema": "pnpm -F schema build",
|
"build:schema": "pnpm -F schema build",
|
||||||
|
|
|
@ -31,15 +31,18 @@ FROM mcr.microsoft.com/playwright:focal as production
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y curl \
|
||||||
|
&& curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm
|
||||||
|
|
||||||
COPY --from=builder /app/pnpm-*.yaml ./
|
COPY --from=builder /app/pnpm-*.yaml ./
|
||||||
COPY --from=builder /app/package.json ./
|
COPY --from=builder /app/package.json ./
|
||||||
COPY --from=builder /app/server/dist ./server/dist
|
|
||||||
COPY --from=builder /app/server/package.json ./server/package.json
|
COPY --from=builder /app/server/package.json ./server/package.json
|
||||||
|
|
||||||
RUN pnpm install -F server --frozen-lockfile --prod
|
RUN pnpm install -F server --frozen-lockfile --prod
|
||||||
|
|
||||||
|
COPY --from=builder /app/server/dist ./server/dist
|
||||||
|
|
||||||
EXPOSE 3100
|
EXPOSE 3100
|
||||||
|
|
||||||
ENV PORT 3100
|
ENV PORT 3100
|
||||||
|
|
|
@ -10,6 +10,7 @@ const bootstrap = async () => {
|
||||||
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
|
app.enableCors({ credentials: true });
|
||||||
app.enableShutdownHooks();
|
app.enableShutdownHooks();
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { join } from 'path';
|
||||||
import { PDFDocument } from 'pdf-lib';
|
import { PDFDocument } from 'pdf-lib';
|
||||||
import { Browser, chromium } from 'playwright-chromium';
|
import { Browser, chromium } from 'playwright-chromium';
|
||||||
|
|
||||||
export const DELETION_TIME = 10 * 1000; // 10 seconds
|
export const DELETION_TIME = 10 * 1000 * 1000; // 10 seconds
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PrinterService implements OnModuleInit, OnModuleDestroy {
|
export class PrinterService implements OnModuleInit, OnModuleDestroy {
|
||||||
|
|
Loading…
Reference in New Issue