How to solve 504: GATEWAY_TIMEOUT error in vercel deployment - timeout

I have deployed my next js project in vercel it's showing 504: GATEWAY_TIMEOUT error on those pages where i have added getServerSideProps function. I am not calling any api request on this getServerSideProps.I am just using this function so that i can't get undefined query values when refreshing the page.
Error image is here:
enter image description here
My code in which page this error is showing,
export async function getServerSideProps(context) {
return {
props: {},
};
}
Everything is working fine in localhost but when i deployed my project in vercel it's giving me this timeout error only on those pages where i have used this getServerSideProps. I had already checked after removing the getServerSideProps and after deploying it's wokring fine in vercel but i am getting undefined value of the queries. How can i solve this problem?
I am expecting not to get this error and also not gettiing undefined value of queries after refreshing.

Related

bootstrap-fileinput with ASP.NET MVC - Form Submit

I wanted to use this plugin (bootstrap-fileinput) to do some simple file upload. Now I'm pretty sure I removed the most to keep a simple file upload via form submit.
script type="text/javascript">
$("#input-id").fileinput({ 'maxFileCount' : 1,'showUpload': false, 'showPreview': false, 'uploadAsync': false, 'showRemove': false, 'showClose': false, 'showCaption': false });
</script>
Still it seems to wanna upload something Asynchronously. It throws a javascript error: Error error not found undefined
Looking in the network log of chrome I see it wants to do this:
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:64251/File/UploadFile
Why does it do this? What am I forgetting? I just want to upload the file data when I click the submit button and let it then process everything by the controller. Not asynchronously and not via ajax.
Thanks for the help

API call not working from Azure

I have an test API (get method) which I have deployed on production with test data.
This API if I call from anywhere directly from Browser , it works perfectly.
I created a web application, just a submit click button, to call that API. I deployed web application on Azure.
It doesn't work. It keeps giving me Operation has timed out exception. API doesn't get a hit. API get request works from browser. I tried to using logger in api, log file remains blank.
Can please anyone help me in this?
EDIT:
When I call through browser, I get following response
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ArrayOfMessage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ValidationWebApi">
<Message>
<MessageDesc>
[{"NO":"111","NAME":"Miss Jane ","EXTENSION":"","MOBILE":"","EMAIL_ID":SOME EMAIL ID}]
</MessageDesc>
<MessageId i:nil="true"/>
<WebApiInfo i:nil="true"/>
<isValid>1</isValid>
</Message>
</ArrayOfMessage>
But if I call through Azure hosted site, I get following error...
`System.Net.WebException: The operation has timed out at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at System.Net.WebClient.DownloadString(String address) at Test.btnSubmit_Click(Object sender, EventArgs e)
Edit:
The way this has been called to check whether it gets hit or not is as follows
This is button click event. we are just trying to print this response on screen. Get method is used.
string strApi = "https://domain.com/myApiName/Jane";
try
{
using (var client = new WebClient())
{
var result = client.DownloadString(strApi);
Response.Write(result);
}
}
I get exception on var result statement. It waits there for sometime and gives exception.
Regards,
Ashay
Try enabling CORS ( cross-origin HTTP request ) to you API controller ..
Thanks
Kasam Shaikh

Error opening Laravel project after 30 minutes

I am getting errors when reloading the previously opened tab of my Laravel Project on my browser. There is no error on the page, I mean it loads correctly when I opened it half hour ago.
The error says "Trying to get property of non-object"
4/4 ErrorException
Trying to get property of non-object
(View: C:\xampp\htdocs\demo\resources\views\partials\mainheader.blade.php)
(View: C:\xampp\htdocs\demo\resources\views\partials\mainheader.blade.php)
(View: C:\xampp\htdocs\demo\resources\views\partials\mainheader.blade.php)
ADDED: Only suspicious code that might be causing problem on mainheader.blade.php is, I am using {{ Auth::user()->name }}. But I am still confuse how I can Redirect this exception.
What I thought was, it was due to error in session and token expiration, so I added this code to app/Exception/handler.php
if ($e instanceof \Illuminate\Session\TokenMismatchException) {
return redirect('error/403')->withErrors(['token_error' => 'Sorry, your session seems to have expired. Please try again.']);
}
But, that was not solved. Could you please so me the right way?
Found my mistake. Actually it was on the route, I should have added middleware for Auth.
Route::get('/home', ['middleware' => 'auth', function () {
return view('home');
}]);
Now, that's good and working.

Ember/Rails end-to-end testing error

I have an Ember CLI app with a Rails back-end API. I am trying to set up end-to-end testing by configuring the Ember app test suite to send requests to a copy of the Rails API. My tests are working, but I am getting the following strange error frequently:
{}
Expected: true
Result: false
at http://localhost:7357/assets/test-support.js:4519:13
at exports.default._emberTestingAdaptersAdapter.default.extend.exception (http://localhost:7357/assets/vendor.js:52144:7)
at onerrorDefault (http://localhost:7357/assets/vendor.js:42846:24)
at Object.exports.default.trigger (http://localhost:7357/assets/vendor.js:67064:11)
at Promise._onerror (http://localhost:7357/assets/vendor.js:68030:22)
at publishRejection (http://localhost:7357/assets/vendor.js:66337:15)
This seems to occur whenever a request is made to the server. An example test script which would recreate this is below. This is a simple test which checks that if a user clicks a 'login' button without entering any email/password information they are not logged in. The test passes, but additionally I get the above error before the test passes. I think this is something to do with connecting to the Rails server, but have no idea how to investigate or fix it - I'd be very grateful for any help.
Many thanks.
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'mercury-ember/tests/helpers/start-app';
module('Acceptance | login test', {
beforeEach: function() {
this.application = startApp();
},
afterEach: function() {
Ember.run(this.application, 'destroy');
}
});
test('Initial Login Test', function(assert)
{
visit('/');
andThen(function()
{
// Leaving identification and password fields blank
click(".btn.login-submit");
andThen(function()
{
equal(currentSession().get('user_email'), null, "User fails to login when identification and password fields left blank");
});
});
});
You can check in the Network panel of Chrome or Firefox developer tools that the request is being made. At least with ember-qunit you can do this by getting ember-cli to run the tests within the browser rather than with Phantom.js/command-line.
That would help you figure out if it's hitting the Rails server at all (the URL could be incorrect or using the wrong port number?)
You may also want to see if there is code that needs to be torn down. Remember that in a test environment the same browser instance is used so all objects need to be torn down; timeouts/intervals need to be stopped; events need to be unbound, etc.
We had that issue a few times where in production there is no error with a utility that sent AJAX requests every 30 seconds, but in testing it was a problem because it bound itself to the window (outside of the iframe) so it kept making requests even after the tests were torn down.

Allowing POST method to an HTML page in ASP.NET MVC

Allowing POST method to an HTML page in ASP.NET MVC
I am using ASP.NET with MVC 5.2 and I am integrating RoxyFileManager to my CKEditor.
The integration was fine, the problem is when I try to upload some file to my web server, I got this error:
NetworkError: 405 Method Not Allowed - http://localhost:35418/FileManager/index.html?...
The RoxyFileManager uses the POST method to upload the file and my webserver does not accept it. I can't figure out how can I fix it.
If I put manually an image to my directory I can see it in the file manager, also I can create and exclude folders there.
To clarify my question: I want to know how can I make my webserver accept the POST method to a HTML page, just it. All the relevant information are above. I have a HTML page and want to make it accept POST.
#UPDATE:
I've figured out the problem is a browser issue.
In Google Chrome everything works fine;
In Firefox I get the error above;
In IE things seens to work fine, but it have cache problems (I can upload and edit previously sent files, but I can't see the changes neither the recent file uploads until cache expires);
I'll work on these problems and post the answer here, if successful.
To solve the IE bug it's simple but it's hard-work: You need to add in every ajax call of RoxyFileMan the line cache: false. You need to do it in every .js file on the RoxyFileMan folder.
Example:
$.ajax({
url: d, dataType: "json", async: true, success: function (h) {
for (i = 0; i < h.length; i++) { e.push(new File(h[i].p, h[i].s, h[i].t, h[i].w, h[i].h)) }
g.FilesLoaded(e)
},
error: function (h) { alert(t("E_LoadingAjax") + " " + d) },
cache: false
})
With this, all the ajax made by Roxy will have no cache, solving the IE issue.
To solve the Firefox bug I've changed this in the main.min.js:
BEFORE:
document.forms.addfile.action = RoxyFilemanConf.UPLOAD
AFTER:
$('form[name="addfile"]').attr('action', RoxyFilemanConf.UPLOAD);
I've found this solution here.
And now my file manager is working on all modern browsers.

Resources