2024-01-16 17:13:58 +01:00
2024-01-10 09:58:59 +01:00
2024-01-16 14:28:10 +01:00
2024-01-15 14:35:50 +01:00
2024-01-15 15:26:17 +01:00
2024-01-10 20:45:10 +01:00
2024-01-08 15:17:18 +01:00
2023-12-27 15:45:49 +01:00
2024-01-10 20:50:23 +01:00
2023-12-27 15:45:49 +01:00
2024-01-10 13:27:25 +01:00
2024-01-10 21:36:44 +01:00
2023-12-27 15:45:49 +01:00
2023-12-27 15:45:49 +01:00
2024-01-16 17:13:58 +01:00
2024-01-16 09:17:56 +01:00
2023-12-27 15:45:49 +01:00

ToDo

  • zeleni outline dodati na račune koji imaju attachment čak i ako nisu plaćeni
  • Bug: kod kopiranja računa u idući mjesec prenosi se i uplaćeni iznos
  • Bug: kod sumiranja dodati provjeru je li račun plaćen - to je ispravka i za prethodni bug
  • Forma za editiranje računa:
    • dodati na vrh naziv lokacije
    • forma se razvali (input za unos iznosa) kada je postavljen PDF
  • Popis lokacija:
    • omogućiti collapse za pojedine mjesece

Authentication

Authentication consists of the following parts:

  • next-auth boilerplate
    • middleware.ts = hooks-up next-auth into the page processing pipeline - user session is checked before any page is rendered
    • auth.ts = defines how the authentication is done, and how session is checked (used by middleware)
    • /app/api/[...nextauth]/route.ts = defines route which shows an authentication form

Source:

Multi-User Support

Each location record is marked with a user ID.

All the actions user withUser to fetch user ID, which is then used in all the DB operations.

Deploying

The deployment is done via Docker:

  • build docker image
  • deploy Docker service

Building Docker image

Run the following command:

docker build . -t utility-bills-tracker:1.0.0

The image will be stored in the local Docker instance.

Deploying Docker service

Run the following command:

docker stack deploy \
    -c docker-compose-deploy.yml \
    utility-bills-tracker

Implementation details

Issues with HOSTNAME

When deplyed via docker and published via Cloudflare there's an issue with HOSTNAME env variable:

  • if left unset, the server will use IP address assigned to container by Docker (i.e. 10.0.20.3) and will not accept connections from outside
▲ Next.js 14.0.2
- Local:        http://68db6c9ebafe:80
- Network:      http://10.0.20.3:80
  • if set to "0.0.0.0" the server will serve static pages, but will reject API calls when submitting form
▲ Next.js 14.0.2
- Local:        http://localhost:80
- Network:      http://0.0.0.0:80

utility-bills-tracker_web-app.1.Error: Invalid Server Actions request.

`x-forwarded-host` header with value `0.0.0.0:80` does not match `origin` header with value `rezije.app` from a forwarded Server Actions request. Aborting the action.
  • if set to "rezije.app" the server will not start since the IP address it resolves with the given FQDN does not match any of the IP addresses assigned to the container
▲ Next.js 14.0.2
- Local:        http://localhost:80
- Network:      http://0.0.0.0:80

utility-bills-tracker_web-app.1.Error: Invalid Server Actions request.

`x-forwarded-host` header with value `rezije.app:80` does not match `origin` header with value `rezije.app` from a forwarded Server Actions request. Aborting the action.

So there are the following issues:

  • server will not accept external request - can be fixed by setting HOSTNAME to 0.0.0.0
  • server rejects API requests - can be fixed by adding serverActions.allowedOrigins option to nextjs.config.js file

So these are the fixes which were implemented in order to be able to run server in production.

This is a hack indicating that I don't understand how the damn thing should be configured!

Even when this hack is emplyed the server still logs the followig error:

failed to get redirect response TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11730:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error: connect ECONNREFUSED 0.0.0.0:443
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
      at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:128:17) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '0.0.0.0',
    port: 443
  }
}

Mongo DB & AVX Instructions

The MongoDB server v > 5.0 will not run on and old machine such as Acer Revo due to it's CPU.

This issue was solved by using an older Mongo DB Version 4.4.27

Description
No description provided
Readme 9.4 MiB
Languages
JavaScript 74.7%
TypeScript 24.3%
Shell 0.9%