I am working on an authentication (login & registration) application using java (android).
Now in order to communicate with a database I was requested to implement it using Laravel web app. I configured everything (Laravel passport) and tested it using postman.
I deployed the website on Heroku and configured pgsql with it. then I duplicated the request in postman and changed the URL.
the problem is that it is adding the new user in the database but it is returning 500 internal server error with no access token
postman response when adding the user:
the new user in the db:
the code responsible for adding users (same code is still working on localhost)
You probably have an error after creating the user. You receive a server-side 500 response because it is not sending you the correct headers to respond in json.
Some APIs require you to send particular headers along with requests, typically to provide additional metadata about the operation you are performing. You can set these up in the Headers tab. Enter any key-value pairs you need and Postman will send them along with your request. As you type, Postman will prompt you with common options you can use to autocomplete your setup, such as Accept
Make sure you are sending Accept: application/json and in your .env file this APP_DEBUG=true to see the error.
Related
hey im new to ionic 3 i prepared a form of contact for my application where the server (php) has to send an email after the filling of the form by the user .
in the server i use the function mail to send email by the server it works find and it sends email even with the appearence of error of No 'Access-Control-Allow-Origin' header
I already added the two headers in my php scripts
header("Access-Control-Allow-Origin: *");
header('Content-Type: text/html; charset=utf-8');
This is not a problem of your ionic app. The server you try to access via api call doens't support CORS. Hopefully this article helps you to solve your problem.
https://blog.ionicframework.com/handling-cors-issues-in-ionic/
There is a tutorial or solution to solve your problem.
Here is the important part for you
Dealing with CORS in Ionic
CORS is only an issue when we are running or testing our app when running ionic serve or ionic run -l.
There are two ways to solve the issue: The first, and easier, solution
is to just allow all origins from your API endpoint. However, we can’t
always control the endpoint we are accessing. What we need, then, is a
request that does not specify an origin.
We can do this by using a proxy server. Let’s look how the Ionic CLI
provides an easily configurable proxy server.
I'm working on creating a basic ReactJS Frontend App that has to send data to an API created with php. My react app is hosted on localhost:3000 using XAMPP and the php file is hosted on localhost:8000. when I try to connect to it I get a connection refused error. I use Axios to send a Post request.
I know this might be very general but any ideas to how to solve this. or go about programming that App?
This is what it currently is. I get a net::ERR_CONNECTION_REFUSED whenever I call it
axios.post('http://localhost:8000/file.php', someData)
Although I'm not sure there's a config option in Axios to specify port, you should be able to send a post request to that port like this:
axois.post('http://localhost:8000')
.then((success) => {
console.log(success)
})
You may need to add a proxy in your package.json file:
"proxy": "http://localhost:8000"
Read more: https://docs.npmjs.com/misc/config#proxy
so I am developing an API first application, Backend with codeigniter-restserver (https://github.com/chriskacerguis/codeigniter-restserver) and front end with Angular2.
I have finished the backend and tested all endpoints with Postman including image upload and delete endpoints, all work fine.
however in addition to authorization http header, some endpoints are guarded by user login session checks. in postman session persist so if I try to upload an image to an endpoint it check if there is anyone logged in, if not it return a status code indicating "not logged in", then I go to the login endpoint login and then return to the image upload endpoint then it works (on Postman).
however from my Angular2 client application even when I call the login endpoint, its still returns the user not loggen in status code. when I then call the image upload endpoint, like it kills the session immediately it recieve response from the REST server.
my question is, what do you think Postman do differently from my Angular2 client App (I am using Angular http and observables).
The Codeigniter restserver is on localhost:80 and Angular2 client App on localhost:4200 in dev mode.
Thanks
I don't know if this is direct answer for your question, but i hope it will help you understand your problem and how to continuo with your project...
I would not depend on Codeigniter's session, since you are working on Single page application and the "rest server" should be stateless.
This also means that you should not look for the sessions in Codeigniter...
Your client application should contain session data. So you should use JsonWebToken (JWS), which can be stored in local storage or cookie on client. For each request you can also send this JWT token to server, where you decode it with some helper function (i'm using JWT helper) and if verification is true, then you make further actions, else return Not authorised or some response
I'm developing a Hybrid App where I use ajax requests to connect to a remote database. The database is accessed through the Laravel(5) framework. When I send requests to the remote laravel web app, I get the following case.
Error with message, No Access Control Allow Origin Header Present.
To solve this problem I added the access control headers to the index.php at public/ directory. Then the above error no longer occurs(Yes, I know that we can do the same using a Middleware and it is the recommended way). But then an internal server error occurs saying csrf Token mismatch exception. I know that if this was a web appilication, we could have easily added the csrf_token. Since this is a hybrid app, I cant set a token since I can't run any PHP here and I can't obtain a token by an ajax request.
Up to now, I have read almost every thread related to this in Laravel Forums. But there were no feasible answer. Does anyone have an idea about how to solve this issue?
Thanks in Advance!
I have gone through links that provide some CURL request samples for AZURE push notifications but none of them works for me.
Like in this url CURL request using Ruby language is provided but like others it is also not working.
"Internal Server Error (500)"
occurred every time when I made a request using CURL requests.
If anybody can provide me with working code of CURL request for AZURE push notifications then it would be convenient for me to solve the issue. Keeping in mind that push notifications from web portal of AZURE are working absolutely fine.
May I know whether you are using Azure Service Bus Notification Hub? If so, the most likely problem from my experience is you may haven't formatted the request properly. It’s needed to prepare the following information, and send them in request headers:
Content-Type: Based on the platform you choose, the value will be different. For instance, for Windows Store apps, content type is application/xml.
ServiceBusNotification-Format: The device type, such as windows.
X-WNS-Type: Push notification type, such as wns/toast.
Authorization: The rules are described in https://msdn.microsoft.com/en-us/library/azure/dn495627.aspx. Pay special attention to the Create SAS Security Token part.
And the request content. The format is different for different devices. For example, for Windows Store apps, it’s needed to use xml like:
<?xml version="1.0" encoding="utf-16"?><toast><visual><binding template="ToastText01"><text id="1">Hello!</text></binding></visual></toast>
If you're using CURL command line, please make sure to use double quotes instead of single quotes.
Also please make sure you have correctly registered the push notification service provider in Azure. For instance, for Windows Store apps, please register the SID and the client secret.
If the issue is still encountered, please share more information. It would be better if you can let us know:
• Are you trying to use the CURL command line or PHP code?
• What kind of device you're using?
• What kind of message you want to send?