IE11 Can't reach this page, but the page is valid and accessible - laravel

I have a bit of a bizarre problem happening in IE11. I'm running DataTables with server-side processing so I had to create a custom button for exporting the full data set, since the default buttons only export the visible data set.
Here's the Yajra DataTables for Laravel configuration for one of my buttons:
'buttons' => [
['extend' => 'csv',
'text' => '<i class="fa fa-file-excel-o"></i> CSV',
'action' => 'function(e,dt,node,config){
var data=$.extend(
true,
dt.context[0].oSavedState,
{
columns:dt.context[0].aoColumns.map(function(col){
return {"data":col.data}
})
})
window.location.href = window.location.href +
"?action=csv&" +
$.param(data);
}'
],
...
The button works fine, it basically compiles a list of the columns and filters and sends the user to a Laravel route that handles the action=csv request and generates an Excel download that triggers automatically in Chrome and Firefox.
In IE11, however, the browser redirects to the Excel download route but throws up a "Can’t reach this page" error message. I can see in the address bar that the URL is correct, and what's odd is that if I just hit Refresh in the browser, the CSV download is triggered and I am given the option to save.
This happens every time I click the download link. What might cause IE11 to think the page can't be reached, when it can?
I tried looking at the request/response headers in network tools and everything seems to be just fine. Any ideas?
Also, I tried rewriting my window.location logic to create a hyperlink element, attach it to the DOM, trigger a click, and it still yields the same thing.
More Information
I tried a few other things and was able to eject the download process at any point in the code up until final response to the browser. The browser responds with a 200 status code, when I look at the Network Tab and view the Response Body, I can see my CSV content right there with appropriate Content Disposition, Content Length headers. The Content-Type header is text/plain, but changing it to text/csv didn't solve the problem.
If the IE's Network Tab renders everything correctly, why might IE's browser renderer show a Page Can't Be Displayed error?

Well, I was finally able to resolve the IE/Edge exporting issue and it comes down to query-string length.
The DataTables grid makes a GET request with a whole bunch of properties related to the query (columns that are visible, which filters were applied, etc.).
Sample Request Params:
{
"action": "csv",
"time": "1529689896632",
"start": "0",
"length": "10",
"order": [
["2","asc"],
["1","asc"]
],
"search": {
"search": "",
"smart": "true",
"regex": "false",
"caseInsensitive": "true"
},
"columns": [
{
"visible": "true",
"search": {
"search": "",
"smart": "true",
"regex": "false",
"caseInsensitive": "false"
},
"data": "programs"
},
// ...
Because there are so many columns, these request params create a very lengthy query-string (in the realm of 3-4000 characters). IE and Edge appear to handle query-strings up to a certain length, as I've noticed some bugs come through where the query-string data was truncated.
I ended up reducing the query-string length by omitting unnecessary and default property values needed for the export. Now IE and Edge both immediately respond with the file download instead of throwing a page not found or other bizarre error.

Related

Profile image is not displayed (error 403)

I'm using Google API (People) list and from returned JSON, I try to use image listed on "url" field:
"photos": [
{
"url": "https://lh3.googleusercontent.com/cm/AATWAfu9TeDbEEC2VEJqYuO1eGr1F7qRpGSvgKlsjMhny8UWSAB_STRGbHQYvwIQzgrp=s100",
"default": true,
"metadata": {
"source": {
"type": "CONTACT",
"id": "4da7eb9a8d9a19e5"
},
"primary": true
}
}
]
Problem is - not all images are displayed, like you can see here:
https://i.postimg.cc/BvPJLyD5/image-2023-01-11-172253699.png.
On console, I see error 403.
When I manually copy link (from "url" link above) and open it in browser, image is normally displayed. Also, when I reload page few times manually, some images are displayed and some other not (randomly).
Is there any solution for this?
It is related to logged status.
If I'm logged into Gmail or Drive, images are randomly displayed.
If I logout from Gmail and use API again, all images are always displayed. It is same for Google Drive, as you can see here: https://issuetracker.google.com/issues/229184403?pli=1

How to show FireFox extension popup only on specific websites? [duplicate]

I have been trying to read up on how to use WebExtension Page Actions by reading the following docs:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/page_action
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/pageAction
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/user_interface/Page_actions
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/pageAction/show
I am unable to find how I configure my extension to show the page action button in the URL bar when a page from example.com has loaded. All the docs seem to assume the page action icon is already visible and shows how to handle clicks on it.
First I thought I could configure it through the manifest but it does not seem to be supported in the same way as content scripts. Then I tried to find an API to call from background.js but have not found any.
How do I show my page action icon on example.com?
Starting with Firefox 59, there will be a much simpler solution. In manifest.json, just use the show_matches property of page_action:
"page_action": {
"show_matches": ["*://*.example.com/*"],
...
}
Digging around the samples I found the following that listens for page loads across all tabs and updates the icon with popup that is configured in the manifest.
background.js
/*
Initialize the page action: set icon and title, then show.
Only operates on tabs whose URL's protocol is applicable.
*/
function initializePageAction(tab) {
if (tab.url.includes("example.com")) {
browser.pageAction.show(tab.id);
}
}
/*
When first loaded, initialize the page action for all tabs.
*/
var gettingAllTabs = browser.tabs.query({});
gettingAllTabs.then((tabs) => {
for (let tab of tabs) {
initializePageAction(tab);
}
});
/*
Each time a tab is updated, reset the page action for that tab.
*/
browser.tabs.onUpdated.addListener((id, changeInfo, tab) => {
initializePageAction(tab);
});
manifest.json
"permissions": [
"tabs",
"activeTab"
],
"content_scripts": [{
"matches": ["*://*.example.com/*"],
"js": ["content_scripts/download.js"]
}
],
"page_action": {
"browser_style": true,
"default_icon": {
"19": "icons/download-19.png",
"38": "icons/download-38.png"
},
"default_title": "Some title",
"default_popup": "popup/popup.html"
},
"background": {
"scripts": ["background.js"]
}

Google Speech API: the requested URL was not found on this server

I am attempting some simple tests on the Google Speech API, and when my server makes a request to this url (below), I get the 404. that's an error response. Not sure why.
https://speech.googleapis.com/v1/speech:recognize?key=[MY_API_KEY]
The body of my request looks like this:
{
"config": {
"languageCode": "en-US",
"encoding": "LINEAR16",
"sampleRateHertz": 16000,
"enableWordTimeOffsets": true,
"speechContexts": [{
"phrases": ["Some", "Helpful", "Phrases"]
}]
},
"audio":{
"uri":"gs://mydomain.com/my_file.mp3"
}
}
And here is the response:
As you can see, that is a valid resource path, unless I'm totally mistaken about something (I'm sure I am): https://cloud.google.com/speech-to-text/docs/reference/rest/v1/speech/recognize
Update 1:, Whenever I try this with the Google API explorer tool, I get this quota exceeded message (even though I have not yet issued a successful request to the API).
{
"error": {
"code": 429,
"message": "Quota exceeded for quota metric 'speech.googleapis.com/default_requests' and limit 'DefaultRequestsPerMinutePerProject' of service 'speech.googleapis.com' for consumer '[MY_API_KEY]'.",
"status": "RESOURCE_EXHAUSTED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developer console API key",
"url": "https://console.developers.google.com/project/[my_project_id]/apiui/credential"
}
]
}
]
}
}
Update 2: Interestingly, I was able to get some 200 ok's using the Restlet client, but even in those cases, the response body is empty (see screenshot below)
I have made a test by using the exact URL and Body content you added to the post, however, I was able to execute the API call correctly.
I noticed that if I add some extra character to the URL, it fails with the same 400 error since it doesn't exist. I would suggest you to verify that the URL of your request doesn't contain a typo and that the client you use is executing the API call correctly. Also, ensure that your calling code is not encoding the url, which could cause issues given the colon : that appears in the url.
I recommend you to perform this test by using the Try this API tool directly or Restlet client which are the ones that I used to replicate this scenario.

Pagination not working - Datatables 1.10.9

I am using server side processing (AJAX requests) to get my table with data. I am getting the correct data. However, pagination is not working. The table info on the bottom left says Showing 1 to 10 of 182 entries and the bottom right shows the page numbers as well but the table shows all the possible records in the first page itself. Here's the code I use:
$(tableId).DataTable({
"paging": true,
"scrollX": true,
"filter": false,
"serverSide":true,
"columns": [
{"data":'transaction_id'},
{"data":'merchant_id'},
{"data":'merchant_provider_id'},
{"data":'transaction_uuid'},
{"data":'transaction_status_type'},
{"data":'transaction_payment_method'},
{"data":'transaction_amount'},
{"data":'transaction_amount_aud'},
{"data":'transaction_aud_exchange_rate'},
{"data":'transaction_amount_usd'},
{"data":'transaction_usd_exchange_rate'},
{"data":'transaction_currency'},
{"data":'transaction_created'},
{"data":'transaction_processed'},
{"data":'transaction_settled'},
],
"ajax": {
"url": requestUrl,
"data": values
}
});
When using server side processing with Datatables, the server side handles dividing the entries into pages. The ajax request will include parameters for offset (start) and page length (length). The server side must use these parameters to select and return the correct entries for each page.

Constantly sending data with ajax in chrome extension

is it possible to post data from google chrome extension to another page, for example every minute? Someone opens chrome and then every minute will be information send to my page.. Thank you for answers.
Yes this is very possible. A short simple example:
background page
//These make sure that our function is run every time the browser is opened.
chrome.runtime.onInstalled.addListener(function() {
initialize();
});
chrome.runtime.onStartup.addListener(function() {
initialize();
});
function initialize(){
setInterval(function(){sendData()},60000);
}
function sendData(){
//Assuming data contains the data you want to post and url is the url
$.post(url,data);
}
Manifest.json
We need to request host permissions for where we are posting. Something along the lines of "http://www.example.com/postHere.php". See Match Patterns for more.
{
"name": "Chrome post test",
"version": "0.1",
"description": "A test for posting",
"manifest_version": 2,
"permissions": [
"http://www.example.com/postHere.php"
],
"background": {
"scripts": ["jquery-1.8.3.min.js","background.js"],
"persistent": true
}
}
Try setInterval(). You should wrap your logic in it in your background page. And don't forget to add "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" in your manifest.json if you are excute a string. For more you may want to browse this.

Resources