Thiago R.
Thiago R.
Explore posts from servers
KPCKevin Powell - Community
Created by Thiago R. on 9/27/2024 in #os-and-tools
Can't set absolute paths to Vite Project
Hello I was trying to make sure I could use either typescript namespaces and use absolute file paths for import statements, as this how-to article suggests. my tsconfig.json file is as follows:
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
}
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@src/*": ["./src/*"],
"@data/*": ["./src/data/*"],
"@views/*": ["./src/views/*"],
"@services/*": ["./src/services/*"]
}
}
}
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
}
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@src/*": ["./src/*"],
"@data/*": ["./src/data/*"],
"@views/*": ["./src/views/*"],
"@services/*": ["./src/services/*"]
}
}
}
Also, my vite.config.ts file is as follows:
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
plugins: [react(), tsconfigPaths()],
resolve: {
alias: {
'@src': '/src',
'@data': '/src/data',
'@views': '/src/views',
'@services': '/src/services',
},
},
});
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
plugins: [react(), tsconfigPaths()],
resolve: {
alias: {
'@src': '/src',
'@data': '/src/data',
'@views': '/src/views',
'@services': '/src/services',
},
},
});
However, if I try to use the absolute paths like the following:
import { ErrorPage } from 'src/views/pages'
import { ErrorPage } from 'src/views/pages'
For instance, the project is a react/tsx game catalogue. The mentioned files are already committed there. The editor doesn't recognize it. For instance, I'm using Jetbrains Webstorm. Has anyone here ever have been through this situation?
2 replies
CC#
Created by Thiago R. on 8/17/2024 in #help
Local machine refuses to connect to an ASP.NET Core Web API container
Hello I need to find out how to access my Docker container via the host machine. My connection is refused, no matter the tool I use (browser, curl, wget, javascript's fetch). I've been looking for a solution since yesterday, but no success at all. I've been trying to instantiate two containers within a same docker network, which is basically an ASP.NET Core Web API and a PostgreSQL server. I have 0 Docker knowledge at all. I was using Rider's feature for instantiating containers and it worked properly. However, I decided to use a docker-compose.yml file instead, because I was editing the same environment variables in both containers (such as PostgreSQL credentials and a default user seed data). I've deleted the IDE configuration before I actually start to build the docker-compose.yml file as follows:
version: '3.8'

services:
webapi:
image: trsaints-frontend-api
build:
context: .
dockerfile: Dockerfile
environment:
- JWT_SINGING_KEY=${JWT_SINGING_KEY}
- JWT_ISSUER=${JWT_ISSUER}
- JWT_AUDIENCE=${JWT_AUDIENCE}
- DB_HOST=db
- DB_PORT=5432
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- ALLOWED_HOSTS=${ALLOWED_HOSTS}
- ALLOWED_CORS_DOMAINS=${ALLOWED_CORS_DOMAINS}
- ADMIN_USERNAME=${ADMIN_USERNAME}
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
- ASPNETCORE_URLS=http://localhost:8080
ports:
- "8082:8080"
- "8081:8081"
depends_on:
- db
networks:
- trsaints-network

db:
image: postgres:alpine3.20
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
ports:
- "5433:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- trsaints-network

volumes:
postgres_data:

networks:
trsaints-network:
version: '3.8'

services:
webapi:
image: trsaints-frontend-api
build:
context: .
dockerfile: Dockerfile
environment:
- JWT_SINGING_KEY=${JWT_SINGING_KEY}
- JWT_ISSUER=${JWT_ISSUER}
- JWT_AUDIENCE=${JWT_AUDIENCE}
- DB_HOST=db
- DB_PORT=5432
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- ALLOWED_HOSTS=${ALLOWED_HOSTS}
- ALLOWED_CORS_DOMAINS=${ALLOWED_CORS_DOMAINS}
- ADMIN_USERNAME=${ADMIN_USERNAME}
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
- ASPNETCORE_URLS=http://localhost:8080
ports:
- "8082:8080"
- "8081:8081"
depends_on:
- db
networks:
- trsaints-network

db:
image: postgres:alpine3.20
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
ports:
- "5433:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- trsaints-network

volumes:
postgres_data:

networks:
trsaints-network:
Both containers run properly, I just can't connect to the api container externally.
15 replies