Codeigniter http request and 404 - codeigniter-2

I have a problem with Codeigniter.
This is my code:
http://pastebin.com/scccVP8D
If my url is: example.com/validator/validator/value/323445
Http request response:
323445
404 Page Not Found
The page you requested was not found.
Why do i get an error 404?

I don't see value/323445 anywhere in your code. You just have function validator without any parameter.
So, when you call example.com/validator/validator/value/323445 the page don't egsist.
You need to delete parameter or to add parameter in function and to use it.

Related

Laravel 8: 302 Redirection when POST/PUT methods called

I've newly installed Laravel 8, and setup my api resources.
But when I try to create/update a record, it's redirect me with 302to the home page...
Here is my api.php:
Route::apiResource('addresses', AddressController::class);
In my AddressController.php, my store method:
public function store(CreateAddressRequest $request)
{
return response()->json(Address::create($request->validated()));
}
Need help (to understand), please.
Please set the header in postman - Accept: application/json.
When you create through store() method, you have CreateAddressRequest class which validates your input. When the validation fails it redirects to the previous page and it could redirects to the homepage if there is no previous page.
For API, this behavior is not desirable since you want to return error message (in JSON) instead of redirection.
Example of using validator to return the error. REST API in Laravel when validating the request

MethodNotAllowedHttpException when using Route::delete

I don't know why I get this
I tested the route with
Route::delete("/attachments/{url}","TrixAttachmentController#destroyAttachment");
localhost:3000/api/v1/attachments?url=hDXtilCleTWc6WyiMeWpp9O0xIx3cRyJuEwVPxzL.jpeg
public function destroyAttachment($url){
dd($url);
}
still i get it
localhost:3000/api/v1/attachments?url=hDXtilCleTWc6WyiMeWpp9O0xIx3cRyJuEwVPxzL.jpeg
here ?url it shows it now using get request
call this route via delete method
can you show form
When using the Route::delete, the request is expecting a POST request with a method of DELETE.
If you are hitting the route in the browser using a GET request, this is the sort of error that will be thrown.
If you are calling the route in a browser you need to change that.
Make sure you are calling it on a form using DELETE verb.

Laravel 5.1 random 404 errors

I am using laravel 5.1 framework, I have set up my site using WAMP.
I have handled the errors whoops as it is giving response header except 200 OK.
Now the problem here is,
sometimes existing routes [i.e. working the very next moment if I try] return 404 page with response header 200 OK.
I am unable to figure it out that in which case it is returning 404 page.
Note that I have my own 404 page designed which I found in the response.
My controller code is as below:
public function create($program_id)
{
$projects = $this->mock->mockprojectlist($program_id);
return view('mocks.create', compact('program_id', 'projects'));
}
Can anyone help me with this?

Laravel 5.2 Incorrect Route Model Binding does not show 404

In Laravel 5.2 docs about Implicit route model binding, there is written:
If a matching model instance is not found in the database, a 404 HTTP
response will be automatically generated.
Route:
Route::get('/product/{product}',function(Product $product){
dd($product);
});
When I enter into URL parameter existent ID, everything works as expected. But when I enter into URL nonexistent product ID, I got No query results for model [App\Product]. instead of response 404. Any ideas why?
After searching i found out solution. If you have no specified error template files in resources/views/errors default Laravel message will be shown. Just create 404.blade.php file in resources/views/errors.

xhrPost : from an http view to an https url

using Dojo, is it possible to make an Ajax call using xhrPost from an HTTP view to a HTTPS url ?
The url must be HTTPS (as defined in Struts).
If I simply set "MyCommand" as the 'url' parameter of the xhrGet, I get a 302 error code.
If I transform "MyCommand" using javascript to something like "https://......./servlet/MyCommand" I see the following error in Firebug : "uncaught exception: Permission denied to call method XMLHttpRequest.open".
I'm stuck using both approaches, the only solution I found is to remove the "https" clause in the struts configuration file, and of course this is not a correct solution :)
Thanks for any help.
Best regards,
Nils
connection to https from http involves a different port of the target. This violates the same-origin policy which should be enforced by the browser to the running javascript code.
It should work with an iframe..
dojo.io.iframe encapsulates this behaviour for you
http://docs.dojocampus.org/dojo/io/iframe
If your server responds with a redirect to a non-ssl (correctly to same-origin) page you should be able to read the response (because the iframe is now in the same-origin).

Resources