Handling Ajax Requests with HTTPS in Yajra DataTables Behind a Reverse Proxy #3203
Unanswered
zerpaconcept
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I have an application running behind a reverse proxy. We encountered an issue where URLs were being generated with http instead of https. We resolved this for most parts of the application by adding URL::forceScheme('https'); in the AppServiceProvider. This fixed the issue for general links, but the Ajax requests made by Yajra DataTables were still being generated with http, causing them to fail.
As a workaround, we manually specified the Ajax URL in the HtmlBuilder like this:
public function html(): HtmlBuilder
{
return $this->builder()
->setTableId('users-table') // Unique ID for this DataTable
->columns($this->getColumns())
->ajax(route('users.index'));
}
This works, but I am curious about the following:
How does DataTables generate the Ajax URL by default?
Is there a better or more efficient way to ensure that DataTables always uses https in its requests without needing to override the URL manually?
Any insights or best practices for handling this kind of setup would be greatly appreciated!
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions