Future frontend of https://dtp-stat.ru written in Next.js.
-
Install dependencies:
yarn install
-
Create a file named
.env.local
and fill it with environment variables listed in the next section. -
Generate Prisma typings:
yarn prisma generate
-
Run Next.js in dev mode:
yarn dev
-
Open localhost:3000 in your browser to see the result.
All secrets should never be committed to the git repo, but saved in the environment variables.
Classic version of dtp-stat.ru
runs on Django framework.
Its source is stored in dtpstat/dtp-stat (internal link).
While we transition to Next.js, we still need Django app to serve API requests and missing pages.
DJANGO_BASE_URL={url}
DJANGO_CONTENT_FALLBACK={true | false}
Enabling DJANGO_CONTENT_FALLBACK
makes Next.js route all non-existing resources to Django.
This enables incremental adoption of Next.js, allowing us to convert pages to React one by one.
See next.config.mjs
→ rewrites
for implementation details.
COMMENTS_ARE_PAUSED={true | false}
This app uses Sentry to track runtime errors both on client and server.
Error reporting is disabled by default.
For it to work for a deployment, configure these variables before running yarn build
.
SENTRY_AUTH_TOKEN={token}
SENTRY_DSN={url}
SENTRY_ENVIRONMENT={production | staging | ...}
-
Create new application on the auth0
-
Go to the auth0 application configuration page
-
Set Application URIs.
Values below are for local development on
http://localhost:3000
and deployments tohttps://dtp-map.netlify.app
/https://*--dtp-map.netlify.app
.
Allowed Callback URLs:
http://localhost:3000/api/auth/callback, https://dtp-map.netlify.app/api/auth/callback, https://*--dtp-map.netlify.app/api/auth/callback
Allowed Logout URLs:
http://localhost:3000, https://dtp-map.netlify.app, https://*--dtp-map.netlify.app
Allowed Web Origins:
http://localhost:3000, https://dtp-map.netlify.app, https://*--dtp-map.netlify.app
-
Get the auth0 application values:
DOMAIN
,CLIENT_ID
,CLIENT_SECRET
-
Define these environment variables in
.env.local
, Netlify UI, etc.:AUTH0_CLIENT_ID={client-id} AUTH0_CLIENT_SECRET={client-secret} AUTH0_ISSUER_BASE_URL={url} AUTH0_SECRET={secret}
For local development you will also need to set
AUTH0_BASE_URL=http://localhost:3000
. This variable is automatically configured for Netlify deployments viabuild-on-netlify.mjs
.
-
Create any prisma-supported database any localhost or online (tested with Heroku/PostgreSQL).
-
Define this environment variable in
.env.local
, Netlify UI, etc.:DATABASE_URL="postgres://{user}:{password}@{host}:{port}/{db}"
Initial apply of the db schema:
yarn prisma generate
yarn prisma db push
On every change of the file schema.prisma please run:
yarn prisma db push
On every change of the raw database schema please run:
yarn prisma db pull