anan7
Dockerfile in Tubrorepo
FROM node:16-alpine
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY . .
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED 1
RUN npm ci
RUN npm run -w api dbgen
RUN npm run -w web build
EXPOSE 3000
CMD ["npm", "start", "-w", "web"]
8 replies
Websocket is not defined error
My Next app's _app.tsx file is
import React, { useState } from 'react';
import '../styles/globals.css';
import { AppProps } from 'next/app';
import Head from 'next/head';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { httpBatchLink, createWSClient, wsLink, splitLink } from '@trpc/client';
import { trpc } from '@/utils/trpc';
function getCookie(name: string) {
const cookies = document.cookie.split(";");
for (let cookie of cookies) {
let [cookieName, cookieValue] = cookie.trim().split("=");
if (cookieName === name) return cookieValue;
}
return "empty";
}
export default function SharedApp(props: AppProps) {
const { Component, pageProps } = props;
const [queryClient] = useState(() => new QueryClient());
const [trpcClient] = useState(() =>
trpc.createClient({
links: [
splitLink({
condition: op => { return op.type === "subscription"
},
true: wsLink({
client: createWSClient({
url: 'ws://localhost:8000/trpc',
})
}),
false: httpBatchLink({
url: 'http://localhost:8000/trpc',
headers() {
return {
authorization: getCookie("user-token"),
};
},
}),
})
],
}),
);
return (
<trpc.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>
<Head>
<title>Cravin</title>
<link rel="icon" href="/cravinwebicon16.png" />
<meta name="description" content="An app for serving food" />
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
</Head>
<Component {...pageProps} />
</QueryClientProvider>
</trpc.Provider>
);
}
3 replies