I have a problem with Laravel/Angular AJAX integration :
I can directly go into my laravel routing by putting it on my own but Angular AJAX doesn't work. This is what I get from my browser console :
GET path to my laravel route (Not Found) angular.js:8611
Related
I have made a basic Laravel project and had configured my api.php file to have a GET route when I want to fetch data for my project, but whenever I try to load the data on browser or perform a GET on the link (localhost:8000/data) from postman, it shows Error 404 Not Found. It seems that the GET is not able to find the URL that I had mentioned above. How can I get this issue sorted?
Not 100% sure this applies to you from the question. But Laravel prepends /api/ to API routes by default.
Maybe try requesting from localhost:8000/api/data?
I have a webshop in laravel and always when I load the page the app.js make an ajax request with the same url. My app.js resource file is empty so I think this is a laravel function. Any idea why make the laravel this call and how can I turn off?
I think it is okay, because all your js and css files must be loaded from server tr
and app.js are not exceptions ))
I am working on a project that was developed in core php. But now I have completed in laravel farmework. Now I want to redirect some pages to my laravel routes. Let's take an example.
www.example.com/Special-Feature.php?tid=262 //this core php url
Redirect to :
www.example.com/view/event/262 //my laravel url
Now if I hit this url:
www.example.com/Special-Feature.php?tid=262
it must go to my laravel url:
www.example.com/view/event/262
Can anyone help me how to do using htaccess?
I want to use my laravel installation as a session and request handler without using blade view templates. I've added an auth controller to the app with:
php artisan make:auth
And login, register, forgot password etc. all work perfectly. What I wanna do though is to redirect the user to an angular 4 single page app that resides in a subfolder named dashboard-dist in laravel root which I build independently from the laravel project. In other words I don't want to use the V in MVC of laravel and have angular handle the views.
I want to use restful API calls to laravel controllers to do the rest of back-end business apart from login, register etc.. How can I redirect the user to index.html inside this folder and keep the session goodness at the same time and have restful request handlers work?
1) Compile your angular app
2) Change your angular index.html entry point to be index.blade.php and move it to the views folder, then fix all js and css files connections
3) Create a route to render that view
4) Use return redirect(route) to redirect to that route from wherever you need
5) ...
6) PROFIT!!!11
First I edited the config/view.php:
'paths' => [
resource_path('views'),
public_path('dashboard-dist'),
],
And then built the angular project to reflect that base href change:
ng build --base-href /dashboard-dist/
And voila... Angular 4 inside the laravel goodness.
I am using angular for frontend and laravel for backend.
When I start the client angular app using below command:
ng serve --open --proxy-config proxy.conf.json
It loads js files from laravel backend public folder.
Angular requests (in browser console)
GET http://localhost:4200/server/client/inline.655c959301e57e1e55b1.bundle.js return 404 not found or ::net::ERR_ABORTED
When I open it in browser without port, it loads.
I am using below proxy setting in angular:
{
"/secure": {
"target": "http://localhost:80/server",
"secure": false
},
"/storage": {
"target": "http://localhost:80/server",
"secure": false
}
}
Why its request to
server/client/...............
If you're using ng serve, it should be directed to
http://localhost:4200/inline.655c959301e57e1e55b1.bundle.js
Check your routes path.
The proxy setting doesn't change any setting to the internal routes. Unless you try to access Angular webpack in Laravel Public directory, but it doesn't make sense.
Maybe you can try to build angular without proxy and put in Laravel public dir. See if it's working.