fix: cors

This commit is contained in:
2026-06-06 09:31:31 +05:30
parent 1789fc0abe
commit cb81d476a8
3 changed files with 23 additions and 18 deletions

View File

@@ -61,32 +61,29 @@ Download and run the interactive installer from the [Official PostgreSQL Downloa
```
*(On macOS/Windows, open your terminal/command prompt and run `psql postgres` or use a graphical tool like PgAdmin).*
2. Create a new database named `brew`:
```sql
CREATE DATABASE brew;
```
3. Create a database user with a secure password:
2. Create a database user with a secure password:
```sql
CREATE USER brew_user WITH PASSWORD 'your_secure_password';
```
4. Grant all privileges on the database to your new user:
3. Create the database and set its owner to `brew_user`. Setting the owner guarantees that the user has full table creation privileges on the default `public` schema:
```sql
GRANT ALL PRIVILEGES ON DATABASE brew TO brew_user;
CREATE DATABASE brew OWNER brew_user;
```
5. (For PostgreSQL 15+) Connect to the database and grant schema permissions:
```sql
\c brew
GRANT ALL ON SCHEMA public TO brew_user;
```
6. Exit the PostgreSQL shell:
4. Exit the PostgreSQL shell:
```sql
\q
```
> [!TIP]
> **Troubleshooting "Permission denied for schema public" (PostgreSQL 15+):**
> If you already created the database without setting `brew_user` as the owner and encounter this error, log in as the superuser (`postgres`), connect to the `brew` database, and explicitly grant the schema privileges:
> ```sql
> \c brew
> GRANT ALL ON SCHEMA public TO brew_user;
> ```
> [!NOTE]
> Database tables (such as `users`) are initialized automatically when you start the backend server, as defined in [server/db.js](file:///home/sortedcord/Projects/brew/server/db.js).