Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions backend/Configs/AllowedConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace backend.Configs
{
public class AllowedConfig
{
public string Origins { get; set; }
}
}
18 changes: 18 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /App

# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
ENV ASPNETCORE_HTTP_PORTS=5001
EXPOSE 5001
WORKDIR /App
COPY --from=build /App/out .

ENTRYPOINT ["dotnet", "backend.dll"]
4 changes: 3 additions & 1 deletion backend/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
builder.Services.AddSignalR();

builder.Services.Configure<JwtSettings>(builder.Configuration.GetSection("JwtSettings"));
builder.Services.Configure<AllowedConfig>(builder.Configuration.GetSection("AllowedConfig"));
var jwtSettings = builder.Configuration.GetSection("JwtSettings").Get<JwtSettings>();
var allowedConfig = builder.Configuration.GetSection("AllowedConfig").Get<AllowedConfig>();

builder.Services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
Expand Down Expand Up @@ -90,7 +92,7 @@
{
cors.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials().WithOrigins("http://localhost:8080");
.AllowCredentials().WithOrigins(allowedConfig.Origins);
});

app.UseHttpsRedirection();
Expand Down
3 changes: 3 additions & 0 deletions backend/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"ConnectionStrings": {
"DefaultConnection": "User Id=postgres.qkrcjdvyhdtoxbppdfrd;Password=senha-do-chat;Server=aws-0-sa-east-1.pooler.supabase.com;Port=5432;Database=postgres"
},
"AllowedConfig": {
"Origins": "http://localhost:8080"
},
"JwtSettings": {
"Secret": "123456789101112131415161718192021222324252627282930",
"Issuer": "https://localhost:5000",
Expand Down
6 changes: 6 additions & 0 deletions backend/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"DefaultConnection": "User Id=postgres.qkrcjdvyhdtoxbppdfrd;Password=senha-do-chat;Server=aws-0-sa-east-1.pooler.supabase.com;Port=5432;Database=postgres"
},
"AllowedConfig": {
"Origins": "https://cs-chat-frondend.onrender.com"
},
"AllowedHosts": "*",
"JwtSettings": {
"Secret": "123456789101112131415161718192021222324252627282930",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class Hub {
this.loginToken = localStorage.getItem('@auth');

this.connection = new HubConnectionBuilder()
.withUrl('http://localhost:5136/Hub', { accessTokenFactory: () => this.loginToken })
.withUrl(process.env.VUE_APP_API_URL + '/Hub', { accessTokenFactory: () => this.loginToken })
.configureLogging(LogLevel.Information)
.build();
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/plugins/axios.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";

axios.defaults.baseURL = process.env.VUE_APP_API_URL;
axios.defaults.baseURL = process.env.VUE_APP_API_URL + "/api";
axios.interceptors.request.use(
(config) => {
const token = localStorage.getItem("@auth");
Expand Down