Page 1 of 1

How to get HTTPRequest() working with xampp locally?

Posted: Sat Dec 05, 2020 3:45 pm
by T4r4ntul4
Hi all,

I have on my computer (localhost) a xampp server with a mysql database and php files.
On the same machine i have SpiderBasic with a script with a HTTPRequest() in it.

When i put my local ip in HTTPRequest() and i press F5 for testing it, then it gives a HTTPRequest error.
But if i put my webhost name in HTTPRequest() to my webhost php file. it can succesfully retrieve the contents of the php file.

What is the difference between them? Both are different servers anyway. Locally on the same computer doesnt work, but on my webserver (without changing anything) it works.

I dont need a solution when i need to export it, but i want to have it that it is working with F5 (when developing the software).

Is this possible?

Any help is very appreciated!

Re: How to get HTTPRequest() working with xampp locally?

Posted: Sat Dec 05, 2020 9:07 pm
by plouf
browsers do not allow you to retrieve data between domains (CORS restrictions)
so do you access you local http server using a diffrent port it is consider as cors violation

i have NOT checked with mysql, but i am almost certain that if you install in local browser a CORS disabler plugin (exist for firefox/chrome etc)

https://addons.mozilla.org/en-US/firefo ... ow-origin/
https://addons.mozilla.org/en-US/firefo ... s-unblock/
(both addons untested by me just suggestions)

Re: How to get HTTPRequest() working with xampp locally?

Posted: Sat Dec 05, 2020 11:56 pm
by T4r4ntul4
I tried 3 different add-ons, but doesnt work.

Any other ideas?

Re: How to get HTTPRequest() working with xampp locally?

Posted: Sun Dec 06, 2020 7:50 am
by plouf
the following example code displays "hello" in debugger (so it does access it and reads) with the first plugin -> https://mybrowseraddon.com/access-contr ... pe=install
(note that after isntalled this plugin you must click "on" on top right icon labeled "C" to become orange=active)

Code: Select all

  Procedure HttpGetEvent(Success, Result$, UserData)
    If Success
      Debug Result$
    Else
      Debug "HTTPRequest(): Error"
    EndIf
  EndProcedure
  
  ; Get the content of this file, and display it in the debug window
  ;
  HTTPRequest(#PB_HTTP_Get, "http://192.168.1.10/plouf/hello.php", "", @HttpGetEvent())
php code

Code: Select all

<?php
 echo "hello";
?>

therefore this way it works, if still do not work for you, provide some example code to test it further

Re: How to get HTTPRequest() working with xampp locally?

Posted: Sun Dec 06, 2020 9:25 am
by T4r4ntul4
Hi, thanks for your example, and it works now.

I did something wrong on my part, when i compared your code with mine, i didnt add 'http://' before the ip address, and with the plugin its working now :D

Thank you for your testing.

Re: How to get HTTPRequest() working with xampp locally?

Posted: Tue Dec 08, 2020 5:25 pm
by Kurzer
I had the same problem in my project "database interface module" and got some great help from the user Peter.

If you want to solve the problem without using a browser addon, please have a look in the first post of this thread:
viewtopic.php?p=7403#p7403

The interesting stuff is in section 2) "The following line can be found in the PHP file "config.php" in the config directory..."

Kind regards
Markus