I am developing locally - laravel sail / docker environment - and access my site with http://localhost. Trying to test hCaptcha. Cannot do so locally. It has been suggested to change my /etc/hosts file:
# cat hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.21.0.7 2d23274c42bb
#
changing the 'localhost' in the hosts file to 'test.anydomain.com', and then I can test the captcha services.
If I do this, will i be able to access my local test site by using the url 'test.anydomain.com', that is with some arbitrary web site domain name? Is there a better way to accomplish this? Can you just change the APP_URL in the Laravel .env file? Or would the container be able to pick up on the env('APP_URL') variable value?
When I try to edit the /etc/hosts file, I find that the docker container does not have a text editor like Vim or Nano installed. I suppose I could use [sed] command to change the text from local host to a domain name, but I don't want to mess up my container. (I don't get the ins and outs of docker containers yet).
when trying to change the text using sed, I get the following:
sed -i 's/127.0.0.1 localhost/127.0.0.1 test.rec4life.com/g' /etc/hosts
sed: cannot rename /etc/sedIABEfa: Device or resource busy
On a somewhat related note, I have tried to use Beyond Code's expose.dev service where I could share my local machine via the internet. After initiating the expose service and changing the APP_URL to the shared with expose url. I could share the home page, but if you clicked on a link within the home page, you were sent back to plain old local host.
Not sure if the two (hCaptcha and shared with expose) are related problems.
Hoping the answer is out there.