'How can we call url() with port number in Laravel controller. Node server is running on different port that 8001 and Laravel port is 8000?
My Laravel application is running on 127.0.0.1:8000 port but my node server is running on port 127.0.0.1:8001 which has a node script that scrapes data. how can I call the URL function to point out the 127.0.0.1:8001 port from a Laravel controller to run such a script?
for example, check the comment in the index() in DataScrapingController
class DataScrapingController extends Controller
{
public function index()
{
// Here is the below URL I want to call this URL when a user calls this index
//controller function
"http://127.0.0.1:8001/scrape"
// After scraping the data when this **http://127.0.0.1:8001/scrape** URL call. which
// saves the data in the output.json file here I get the output.json file and return the
// data to the data-scraping blade file.
$data = json_decode(file_get_contents('output.json'));
return view('data-scraping', compact('data'));
}
}
Below image is the node hierarchy in the Laravel application
thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

