After running the Grunt build, the Angular call to PHP results in a 404

I'm really in need of some guidance here, as I'm quite lost building my first ng-app. The issue lies with the Grunt build results where the api calls (php) are not being found.

My folder structure consists of dist->api->index.php, so it's puzzling to me why these calls return a 404 error.

Currently, I'm using MAMP as my server and upon inspection, it seems that the calls include the entire path:

http://disty:8888/api/testimonials

In development, I utilized grunt-serve with a different port instead of MAMP. However, from what I understand, this should not affect production, right?

Perhaps this is nothing significant, but I'm eager to learn and would greatly appreciate any help. Thank you in advance!

Answer №1

To serve PHP files using Grunt, you need to replace grunt-serve with grunt-php and configure the server with a specified base directory and port.

The configuration should look like this:

grunt.initConfig({
php: {
    dist: {
        options: {
            port: 8888,
            base: 'dist/api/',
            keepalive: true,
            open: true
        }
    }
}
});

By following these steps, you will have access to your index.php API.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for saving multiple pieces of data in a single field with Laravel

Is it possible to save multiple data at once using a simple form? controller $status= new PostTable(); $status->language = $request->language; blade <input type="checkbox" value="hindi" name="language[]" id="language"> Hindi model pro ...

Upon reviewing the webpage using an IPAD and AngularJS

I recently completed a web application using AngularJS and PHP. It functions smoothly on Chrome and Firefox, but it encounters loading issues on IE due to the number of JS files. To solve this problem, I will need to reduce the amount of JS files for it to ...

Moving a file from the root directory to a different directory using Php

Hello, I am a beginner in php programming and currently learning the ropes. I have come across a small issue while working with directories structured like this: c:/xampp/htdocs/ -practise + /css + /js + /images - /extra - /folder1 ...

Retrieving information from a database and displaying it in JSON format as a response

Within my MySQL table, I have a set of records that I would like to fetch and display in the format of a JSON response as shown below. "results":[ { "timestamp":"2014-03-04 17:26:14", "id":"440736785698521089", "category":"spo ...

What could be causing the fputcsv function to not write to my CSV file?

For some reason, I've encountered an issue while attempting to write to a .csv file using PHP. The file remains blank and no data is being added. Initially, an AJAX post request is sent to addComment.php, where the intention is to append the POST data ...

What is the best way to eliminate index.html and exclamation mark from a URL when using AngularJs ui-router?

Recently, I've been working on my state configuration in JavaScript Currently, my URL appears as follows: https://i.stack.imgur.com/FEgjx.png I am looking to eliminate 'index.html' and the exclamation mark from my URL, similar to this exa ...

interactive textbox created with the combination of javascript and php

Hello, I am new to JavaScript and jQuery. I am trying to create a dynamic text box using JavaScript that can add and remove rows. When I press the add button, it works well, but when I pressed delete, it deleted the entire table. Below is my JavaScript fu ...

Combining Arrays in AngularJS with an owl-carousel Setting

My goal is to implement an endless scrolling carousel in AngularJS using owl-carousel. The idea is to load new items every time the carousel is fully scrolled and seamlessly merge queried elements with the existing list. However, I've encountered a pr ...

Extracting postal code information from a text

Currently, I am attempting to extract zip codes from address strings. The zip codes can vary in format, such as 23-123 or 50-530. Typically, the address strings follow this pattern: Street 50, 50-123 City My approach involves identifying the position of ...

What is the best way to distinguish between the app ID and version in Ionic framework?

I successfully launched an application on Android using the ionic framework. Now, I am preparing to launch the app on iOS as well. In order to do this, I need to obtain the specific id and version for both iOS and Android separately. The snippet from my ...

PHP is featured in the Lazy Classes program

Currently, I am using an autoloader to include classes by using "glob" to read different directories and push them into an array. Is there a more efficient method for accomplishing this task? $path = './'; $files = array_merge( glob($path.&apos ...

Zend Framework redirect problem: Controller specified is invalid

I'm currently working on a project using Zend Framework 1.12. When all the files are kept in the root folder, everything functions correctly. However, if I create a new folder and move all the files into it, nothing works as expected. This is my cur ...

AngularJS encounters an error message stating, "The data being posted is invalid in syntax according to the client."

Angular post request $http({ method: 'POST', url: '/DineOut/send', contentType:'application/json', dataType:'json&ap ...

Implementing AngularJS drag and drop functionality in a custom directive

I am in search of an example that demonstrates similar functionality to the HTML5 File API using Angular-js. While researching directives for Angular 1.0.4, I found outdated examples that heavily rely on DOM manipulation. Here is a snippet of the pure Ja ...

Create a unique key dynamically based on a specified scope value using AngularJs

I am working with an angular directive that utilizes a title with a key from a messages.properties file. To dynamically generate the key, I want to concatenate 'root.' + scope.value + '.title' like so: titre="{{ 'flux.' + &ap ...

Having trouble choosing elements with angular.element within ng-repeat loop

In my HTML code, I am using an ngRepeat element: <ol id="animationFrame"> <li ng-repeat="animationImage in animationImages" ng-repeat-listener> <img ng-src="{{animationImage.src}}" id="{{animationImage.id}}"> </li> </ol& ...

Encountering undefined id in AngularJS service

I recently went through a tutorial at However, I encountered an issue when attempting to save a new record. The value of newcontact.id is showing as undefined and I'm unable to save the new record. Any ideas on what might be causing this problem? ...

PHP - File_get_contents not recognizing CURL response

Here is the script I'm working on: <?php $auth_token = "privateprivateprivate"; $curl = curl_init("https://api-sandbox.coingate.com/v2/orders/"); $headers = array(); $headers[] = "Authorization: Token " .$auth_token; $output = curl_exec($curl); ...

Steps to access arrays that are embedded in a file and are loaded asynchronously

https://gyazo.com/e80eea9f69c0cbb52cc7929d0a46ea2f The name of the object is totalCount. How can I retrieve the count from it? Object.result was my first attempt, but it returned undefined. For my second attempt: var count = totalCount.resu ...

Monitoring Changes in an Array of Objects with Angular's $watch Feature

Imagine having an array of animal objects linked to the scope. Each object contains a 'name' field and a 'sound' field. After that, I set up a $watch on the array with the objectEquality flag set to true (the third argument). Then, in ...