Skip to content

Commit

Permalink
feat: add configurable CORS origins for deployment flexibility (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
phob authored Feb 11, 2025
2 parents ca1f814 + 5216dc8 commit e42c06a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
13 changes: 2 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ RUN pnpm run build
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine
WORKDIR /app

# Install required dependencies
# RUN apk add --no-cache icu-libs nodejs npm && npm install -g pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apk add --no-cache icu-libs nodejs

# Create necessary directories
RUN mkdir -p config/logs && mkdir -p /mnt/zurg/tvseries && mkdir -p /mnt/zurg/movies \
Expand All @@ -43,12 +40,6 @@ COPY --from=backend-build /app/publish .
# Copy the built frontend app
COPY --from=frontend-build /mediaflick/.next/standalone ./
COPY --from=frontend-build /mediaflick/.next/static ./.next/static
#COPY --from=frontend-build /mediaflick/package*.json ./
#COPY --from=frontend-build /mediaflick/next.config.* ./
#COPY --from=frontend-build /mediaflick/pnpm-lock.yaml ./

# Install production dependencies for frontend
# RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

# Set environment variable for timezone and globalization
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
Expand All @@ -58,7 +49,7 @@ ENV NODE_ENV=production
EXPOSE 3000
EXPOSE 5000

RUN apk add --no-cache icu-libs nodejs
RUN rm -rf ./node_modules

# Start both services using a shell script
COPY start.sh .
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ services:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=http://+:5000
- NODE_ENV=production
- CORS_ORIGINS=http://localhost:3000
restart: unless-stopped
4 changes: 2 additions & 2 deletions src/PlexLocalScan.Api/ServiceCollection/Cors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ public static class Cors
{
public static IServiceCollection AddCorsPolicy(this IServiceCollection services)
{
var corsOrigins = Environment.GetEnvironmentVariable("CORS_ORIGINS")?.Split(',') ?? new[] { "http://localhost:3000" };
services.AddCors(options =>
options.AddDefaultPolicy(policy =>
policy
.WithOrigins("http://localhost:3000")
.WithOrigins("http://localhost:5000")
.WithOrigins(corsOrigins)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials()
Expand Down

0 comments on commit e42c06a

Please sign in to comment.