Skip to content

[reverse proxy] Use getApiBase() to get GraphQL Endpoint for events#1397

Merged
jokob-sk merged 3 commits intonetalertx:mainfrom
luckylinux:fix-events
Jan 9, 2026
Merged

[reverse proxy] Use getApiBase() to get GraphQL Endpoint for events#1397
jokob-sk merged 3 commits intonetalertx:mainfrom
luckylinux:fix-events

Conversation

@luckylinux
Copy link
Contributor

@luckylinux luckylinux commented Jan 9, 2026

Use getApiBase() to get GraphQL Endpoint for front/appEventsCore.php and front/events.php.

Note that you might want to check the Variable Names and see if baseUrl or apiBase is preferrable to you (it might not be fully consistent with the rest of the Code).

Summary by CodeRabbit

  • Refactor
    • Optimized API URL construction across multiple modules for better consistency and maintainability. Internal improvements to endpoint handling; no visible changes to user-facing functionality.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Three PHP files replace manual API endpoint construction using protocol/host/port with a centralized getApiBase() function, simplifying URL composition across GraphQL and REST API calls while maintaining existing request logic and headers.

Changes

Cohort / File(s) Summary
API Base URL Centralization
front/appEventsCore.php, front/deviceDetailsTools.php, front/events.php
Replaced hard-coded GraphQL/REST endpoint construction using window.location.protocol, host, and port with dynamic getApiBase() function. Updated all AJAX calls to use unified base URL instead of manual composition. Removed redundant local baseUrl variables and GRAPHQL_PORT dependencies while preserving existing request headers, authentication, and response handling logic.

Poem

🐰 A rabbit hops through code so spry,
No more endpoints spread far and wide,
One base URL, clean and neat,
Makes the code refactor complete! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing manual GraphQL endpoint construction with getApiBase() in event-related files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
front/deviceDetailsTools.php (3)

221-222: Remove redundant apiBase declaration.

The apiBase constant is already declared at the top level (lines 213-214) and is accessible throughout the script. This redeclaration creates unnecessary variable shadowing.

♻️ Proposed fix
-            // Build base URL dynamically
-            const apiBase = getApiBase();
-

586-587: Remove redundant apiBase and apiToken declarations.

Both constants are already declared at the top level (lines 213-215). The redeclaration is unnecessary and creates variable shadowing.

♻️ Proposed fix
-            // Build base URL dynamically
-            const apiBase = getApiBase();
-            const apiToken = getSetting("API_TOKEN");   // optional token if needed
-

637-638: Remove redundant apiBase declaration.

The apiBase constant is already declared at the top level (lines 213-214). This redeclaration creates unnecessary variable shadowing.

♻️ Proposed fix
-            // Build base URL dynamically
-            const apiBase = getApiBase();
-
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0727798 and 7b15329.

📒 Files selected for processing (3)
  • front/appEventsCore.php
  • front/deviceDetailsTools.php
  • front/events.php
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{py,php,js}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use environment variables (NETALERTX_DB, NETALERTX_LOG, etc.) everywhere instead of hardcoding /data/db or relative paths. Use /data for persistent config/db, /tmp for runtime logs/api/nginx state

Files:

  • front/deviceDetailsTools.php
  • front/events.php
  • front/appEventsCore.php
🔇 Additional comments (5)
front/appEventsCore.php (1)

27-28: LGTM! Clean centralization of API base URL.

The introduction of getApiBase() properly abstracts the API endpoint construction, making it reverse-proxy friendly. The variable naming is consistent with other files in this PR.

front/events.php (2)

163-166: LGTM! Consistent API base URL handling.

The centralized getApiBase() approach properly supports reverse proxy configurations. The comment on line 163 helps document the change.


209-211: LGTM! Consistent pattern with getEventsTotals.

The API base URL construction matches the pattern established in getEventsTotals(), ensuring consistency across event-related endpoints.

front/deviceDetailsTools.php (2)

213-214: LGTM! Centralized API configuration.

The top-level apiBase and apiToken declarations provide a single source of truth for API configuration across all tool functions.


226-256: LGTM! Proper use of centralized API base.

The nmap scan function correctly uses the centralized apiBase for endpoint construction with proper error handling and response formatting.

@jokob-sk jokob-sk merged commit dc673ec into netalertx:main Jan 9, 2026
6 checks passed
@luckylinux luckylinux deleted the fix-events branch January 10, 2026 12:59
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.

2 participants