Skip to content
This repository was archived by the owner on Jul 15, 2025. It is now read-only.

Fix tag deletion CORS issue and improve error handling#265

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-233
Closed

Fix tag deletion CORS issue and improve error handling#265
Copilot wants to merge 3 commits intomainfrom
copilot/fix-233

Conversation

Copy link

Copilot AI commented Jul 10, 2025

This PR resolves the "Cannot delete tags" issue where users were experiencing 403 Forbidden errors when attempting to delete Docker image tags.

Root Cause

The issue was caused by an invalid CORS configuration in the backend that violated the CORS specification:

  • Access-Control-Allow-Origin: "*" was combined with Access-Control-Allow-Credentials: true
  • This combination is explicitly forbidden by the CORS spec and causes browsers to reject requests

Changes Made

🔧 Backend Fixes

  • Fixed CORS configuration: Now properly handles origin-specific CORS headers vs wildcard origins
  • Improved error handling: Enhanced logging and error responses in tag deletion handler

🎯 Frontend Improvements

  • Enhanced TagService: Added comprehensive error logging and better timeout handling
  • Improved server actions: Better error handling in SvelteKit server actions with user feedback
  • Removed dead code: Eliminated unused deleteTagBackend function that called non-existent /api/delete endpoint

📝 Configuration Updates

  • Added PUBLIC_BACKEND_URL: Explicitly set in docker-compose.yml for proper frontend-backend communication
  • Updated .env.example: Added detailed documentation for environment variables
  • Better defaults: Ensured reliable configuration for Docker deployments

Example Error Before Fix

POST http://192.168.178.118:8987/details/sscm/management/1.0.1?/deleteTag 403 (Forbidden)

Testing

  • ✅ Backend builds successfully with Go
  • ✅ Frontend builds successfully with SvelteKit
  • ✅ CORS configuration tested and validated
  • ✅ URL construction and encoding verified
  • ✅ Error handling paths tested with mock services

For Users Experiencing This Issue

Ensure these environment variables are properly configured:

PUBLIC_BACKEND_URL=http://localhost:8080  # For Docker deployments
REGISTRY_STORAGE_DELETE_ENABLED=true     # Enable registry deletion
PUBLIC_LOG_LEVEL=DEBUG                   # For troubleshooting

Fixes #233.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Bug: Cannot delete tags Fix tag deletion CORS issue and improve error handling Jul 10, 2025
Copilot AI requested a review from kmendell July 10, 2025 22:13
@kmendell kmendell closed this Jul 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Cannot delete tags

2 participants