Skip to content
Snippets Groups Projects
Commit aaaf79d2 authored by Amanda Pollyanna da Silva Rodrigues's avatar Amanda Pollyanna da Silva Rodrigues
Browse files

ADD CORS permission

parent 509e411c
No related branches found
No related tags found
1 merge request!20ADD CORS permission
# code config
NODE_ENV=development
PORT=3000
# db config
DB_HOST=localhost
DB_USER=postgres
DB_PASSWORD=123mudar
DB_NAME=treinamento
DB_PORT=5432
DB_URL=postgresql://postgres:123mudar@localhost:5432/treinamento
# secret
APP_SECRET=hash_aleatoria_bem_longa
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"packageManager": "pnpm@10.5.2", "packageManager": "pnpm@10.5.2",
"dependencies": { "dependencies": {
"bcrypt": "^5.1.1", "bcrypt": "^5.1.1",
"cors": "^2.8.5",
"dotenv": "^16.4.7", "dotenv": "^16.4.7",
"dotenv-expand": "^12.0.1", "dotenv-expand": "^12.0.1",
"drizzle-orm": "^0.40.0", "drizzle-orm": "^0.40.0",
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/bcrypt": "^5.0.2", "@types/bcrypt": "^5.0.2",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.9", "@types/jsonwebtoken": "^9.0.9",
"@types/node": "^22.13.9", "@types/node": "^22.13.9",
......
...@@ -11,6 +11,9 @@ importers: ...@@ -11,6 +11,9 @@ importers:
bcrypt: bcrypt:
specifier: ^5.1.1 specifier: ^5.1.1
version: 5.1.1 version: 5.1.1
cors:
specifier: ^2.8.5
version: 2.8.5
dotenv: dotenv:
specifier: ^16.4.7 specifier: ^16.4.7
version: 16.4.7 version: 16.4.7
...@@ -39,6 +42,9 @@ importers: ...@@ -39,6 +42,9 @@ importers:
'@types/bcrypt': '@types/bcrypt':
specifier: ^5.0.2 specifier: ^5.0.2
version: 5.0.2 version: 5.0.2
'@types/cors':
specifier: ^2.8.17
version: 2.8.17
'@types/express': '@types/express':
specifier: ^4.17.21 specifier: ^4.17.21
version: 4.17.21 version: 4.17.21
...@@ -539,6 +545,9 @@ packages: ...@@ -539,6 +545,9 @@ packages:
'@types/connect@3.4.38': '@types/connect@3.4.38':
resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==} resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==}
'@types/cors@2.8.17':
resolution: {integrity: sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==}
'@types/express-serve-static-core@4.19.6': '@types/express-serve-static-core@4.19.6':
resolution: {integrity: sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==} resolution: {integrity: sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==}
...@@ -674,6 +683,10 @@ packages: ...@@ -674,6 +683,10 @@ packages:
resolution: {integrity: sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==} resolution: {integrity: sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
cors@2.8.5:
resolution: {integrity: sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==}
engines: {node: '>= 0.10'}
create-require@1.1.1: create-require@1.1.1:
resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
...@@ -1679,6 +1692,10 @@ snapshots: ...@@ -1679,6 +1692,10 @@ snapshots:
dependencies: dependencies:
'@types/node': 22.13.11 '@types/node': 22.13.11
'@types/cors@2.8.17':
dependencies:
'@types/node': 22.13.11
'@types/express-serve-static-core@4.19.6': '@types/express-serve-static-core@4.19.6':
dependencies: dependencies:
'@types/node': 22.13.11 '@types/node': 22.13.11
...@@ -1827,6 +1844,11 @@ snapshots: ...@@ -1827,6 +1844,11 @@ snapshots:
cookie@0.7.1: {} cookie@0.7.1: {}
cors@2.8.5:
dependencies:
object-assign: 4.1.1
vary: 1.1.2
create-require@1.1.1: {} create-require@1.1.1: {}
debug@2.6.9: debug@2.6.9:
......
...@@ -3,11 +3,17 @@ import dotenv from 'dotenv' ...@@ -3,11 +3,17 @@ import dotenv from 'dotenv'
import User from './handlers/user'; import User from './handlers/user';
import implant from './handlers/implants' import implant from './handlers/implants'
import { tokenAuthenticator} from '@/middleware/auth' import { tokenAuthenticator} from '@/middleware/auth'
import cors from 'cors'
// Carregar variáveis de ambiente // Carregar variáveis de ambiente
dotenv.config() dotenv.config()
const app = express() const app = express()
app.use(cors({
origin: 'http://localhost:5173',
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
}));
// Middlewares // Middlewares
app.use(urlencoded({ extended: true })) app.use(urlencoded({ extended: true }))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment