Skip to content

Reverse proxies fixed#117

Merged
ddelpiano merged 5 commits intodevelfrom
fix/nginx
Jul 14, 2025
Merged

Reverse proxies fixed#117
ddelpiano merged 5 commits intodevelfrom
fix/nginx

Conversation

@ddelpiano
Copy link
Member

No description provided.

@ddelpiano ddelpiano requested a review from Copilot July 14, 2025 12:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances proxy configurations across Vite and Nginx to better handle CORS and redirect headers, and updates the login component to parse session cookies differently.

  • Added a new /versions proxy route in both Vite and Nginx with CORS settings.
  • Refactored Login.jsx to treat cookies as an object instead of an array.
  • Consolidated CORS and redirect handling in Nginx, including a shared @handle_303 block.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
vite.config.js Added /versions proxy, refined redirect handling.
src/components/Auth/Login.jsx Changed session cookie lookup and storage logic.
nginx/default.conf Introduced CORS headers globally and unified 303 redirects.
Comments suppressed due to low confidence (1)

src/components/Auth/Login.jsx:53

  • The logic assumes _cookies is an object with a session property, but JSON.parse(cookies) originally returns an array. Consider reverting to the find approach or converting the array to an object keyed by cookie name.
        const sessionCookie = _cookies && Object.prototype.hasOwnProperty.call(_cookies, 'session') ? _cookies['session'] : undefined;

setCookie(
'session',
sessionCookie.value,
sessionCookie,
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setCookie expects a string value, but sessionCookie may be an object. Pass sessionCookie.value or serialize the correct property instead.

Copilot uses AI. Check for mistakes.
expires: expires
}));
localStorage.setItem("token", sessionCookie.value)
localStorage.setItem("token", sessionCookie)
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are storing the entire cookie object in localStorage instead of its string value. Use sessionCookie.value for the token.

Suggested change
localStorage.setItem("token", sessionCookie)
localStorage.setItem("token", sessionCookie.value || sessionCookie)

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +30

# CORS headers
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Credentials true always;
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CORS headers are repeated in multiple location blocks. Consider moving common headers into a shared include or a global http/server context to reduce duplication.

Suggested change
# CORS headers
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Credentials true always;

Copilot uses AI. Check for mistakes.
# Handle 303 redirects for spec endpoint
location @handle_303 {
internal;
proxy_pass https://uri.olympiangods.org;
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @handle_303 block uses a static proxy_pass URL, which discards the original request URI. Use $request_uri or append $uri to preserve the path when forwarding.

Suggested change
proxy_pass https://uri.olympiangods.org;
proxy_pass https://uri.olympiangods.org$request_uri;

Copilot uses AI. Check for mistakes.
});
},
},
'^/[^/]+/[^/]+/versions$': {
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new versions proxy block duplicates header-handling logic from other routes. Consider extracting common proxy event handlers into a helper to avoid repetition.

Copilot uses AI. Check for mistakes.
@ddelpiano ddelpiano merged commit 15de9d0 into devel Jul 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant