MERN & Heroku: 404 - heroku

I have deployed my MERN Application using heroku, and my login doesn't work and it shows me 404 status,
I've deleted localhost:5000 from the fetch in the frontend but i still get the same error
const response = await fetch('/users/login', {
mode:"no-cors",
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
and the error i get is:
Login.js:25 POST https://firm-management-ensi.herokuapp.com/users/login 404 (Not Found)

Related

Ajax request django rest framework

I've got a problem. Every time I have to clear caches and cookies first and then the AJAX request can be requested successfully. Otherwise I will get 403 response from the server, which is Django RESTful framework.
This is what I request
$.ajax({
url: url_add,
type : 'PATCH',
dataType: 'json',
data: {
'followup_customer': note,
},
statusCode: {
200: function() {
window.location.reload();
}
},
});
You should add a correct HTTP header, containing CSRF token as described in django docs.

POST Request for Ionic using Ripple in Chrome Browser

I am rather new to Ionic App development and need help.
I am using Visual Studio 2015 for development and Chrome Browser with Ripple for rendering the application.
The problem is, when making an Ajax Post request to an API it gives me a 404 (Not Found error) because the POST url gets prepended with a rippleApi and TinyHippos Uri.
I am wondering what causes this prepending of the URI
The following is my Controller:
var request = $http({
method: "post",
url: myPostLink,
data: {},
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
request.success(function (data) {
console.log(data);
});

AngularJS CORS Web API Call

I am trying to make a request to the Eventbrite API. I can successfully make a call from Postman (chrome extension similar to fiddler)
url: https://www.eventbriteapi.com/v3/users/me/owned_events
Header: authentication : Bearer Y5R3SQRPRZBULIHYQHTD
This successfully gets back what I'm looking for. When I try to make the same call through AngularJS
function getLiveEvents() {
return $http.get(url, {
cache: true,
headers: {
'Authorization': 'Bearer Y5R3SQRPRZBULIHYQHTD',
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
}
}).then(function (response) {
return response.data;
});
}
I always get the error XMLHttpRequest cannot load https://www.eventbriteapi.com/v3/users/me/owned_events?status=live. The request was redirected to 'https://www.eventbriteapi.com/v3/users/me/owned_events/?status=live', which is disallowed for cross-origin requests that require preflight.
Is there something I can do with my AngularJS request so that it will be successful?
FYI: The access-token is real, I'm not concerned about someone using it because it's just a test account.

Ajax Post request not authorized

I have this webapp where I make a post request using Ajax from Domain A to a rest service on Domain B
Domain B has been set up to serve the response with the CORS Access-Control* headers in order to get the cross-domain posting to work
Headers in response from domain B:
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Methods: POST GET OPTIONS
Access-Control-Allow-Origin: https://sub.domain-a.com
Access-Control-Max-Age: 180
The Ajax code
$.ajax({
url: 'https://sub.domain-b.com',
type: 'POST',
contentType: 'application/json',
headers: {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
},
data: json,
dataType: 'json',
xhrFields: {
withCredentials: true
},
success: function (data) {
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
I am logged in on both domains and my request sends the necessary cookie (withCredentials=true), but I am still getting a 403 Forbidden from the response
Both domains are using SSL a certificate
I am beginning to wonder if the SSL's are causing the problem as this worked before and I am getting nothing in my logs
Are there anyone here that have any experience with something similar?
Any pointers?
It could be something similar to this issue:
Pre-flight OPTIONS request failing over HTTPS
Typically when the issue is with SSL and the preflight request though you wouldn't get back a 403, you'd just get the OPTIONS request aborting.
How does the service authenticate and authorise? Are you using self-signed certificates? It sounds like you're correct in thinking that SSL is causing the issue and without more info it's hard to say what your specific problem is.

302 in JQuery Mobile App

I have a JQuery Mobile app. This app is currently running on localhost. I am relying on some services hosted on some of my backend servers. When I run a query, I noticed in fiddler that I am getting a 302. This 302 is causing my service call to fail.
If I copy-and-paste the URL of the service in my browser window, everything works fine. Here is my JQuery code
$.ajax({
url: GetServiceUrl(),
type: "GET",
data: vm,
contentType: "application/json",
success: service_Succeeded,
error: service_Failed
});
function service_Succeeded(result) {
alert("received!");
}
function service_Failed() {
alert("oops");
}
function GetServiceUrl() {
var url = "http://www.mydomain.com/services/endpoint";
return url;
}
Why am I getting a 302 from my app?
Thank you
your service is sending a redirect request. Maybe you require a login?

Resources