Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

WallyJ's avatar

Port 80 getting added to URLs after POST

I have a form that, when submitted, goes to the correct url, but the url has an extra port 80 in it for seemingly no reason.

URL that I should reach: https://re-crm-wallyj.c9users.io/contacts/4/contactnotes

URL that I reach: https://re-crm-wallyj.c9users.io:80/contacts/4/contactnotes

I'm thinking it's a config issue. I'm developing on a C9 server.

Thoughts? Thanks!

0 likes
28 replies
Snapey's avatar

what is the app_url in .env or config

Snapey's avatar

And this is just when you post the form?

what does the action look like on your form

WallyJ's avatar
<div class="card-block">
          <form method="POST" action="/contacts/{{ $contact->id }}/contactnotes/">
          {{ csrf_field() }}
          <div class="form-group">
             <textarea name="contactnotetext" placeholder="Your note here" class="form-control">
             </textarea>
          </div>
          <div class="form-group">
             <button type="submit" class="btn btn-primary">Add Note</button>
          </div>
          </form>
</div>
Snapey's avatar

So the router should create links that are based on the current request.

Only if the link loading the form has :80 appended, will the action also have :80 appended?

Unless you have some strange config on your web server that is rewriting the requests?

WallyJ's avatar

I am using Cloud9 with their online servers. It's running Apache, PHP, MySQL, and PHPMYAdmin. Pretty standard stuff. I have found other forum posts with this problem, but not any answers that work on my Cloud9 server. I have sent Cloud9 support an email but they haven't figured it out yet either. I have found the issue from others using Laravel, so I don't think it's a Cloud9 issue. I think it's a Laravel issue.

Snapey's avatar

So, you are happily navigating around your site... at what point does :80 appear?

WallyJ's avatar

Only when I post the form. I have another form that works fine. That form uses a controller as its action instead of a URL.

I may switch the way my broken form works, but I shouldn't have to.

Thanks for your help.

WallyJ's avatar

I wish I could figure this out because I just want to develop without the headaches of a server that wants to act up. Any other ideas that you have is helpful.

Cronix's avatar

Yeah, use a real server that you have control over. Digital Ocean droplets start at $5/month.

WallyJ's avatar

If I go with Digital Ocean, do I have to install Apache and PHP and mysql, etc.?

And do they have a built in editor like Cloud9?

WallyJ's avatar

I'm down for using Forge. Do they have an online editor or do I have to set up a local server and then push my files to Forge?

Cronix's avatar

If you use Forge, I'd recommend developing on Laravel Homestead. It's the same Ubuntu install that Forge uses, except Forge (being the live site) has more security in place as far as the OS. It's the best of both worlds because you are developing in the exact same environment as your live server, so you know everything will just work.

The best workflow is to have a github repo, or other web based git repo like BitBucket, with your code. They can be either public or private repos. You can easily set up Forge to use that account and use automatic deployments. You tell it which repo and branch to watch, usually master, and anytime you commit or merge to master it will automatically push the changes to your server, so you don't have to do a thing. It can even do things like run artisan migrate to migrate your databases, and anything else you normally do.

WallyJ's avatar

I appreciate your idea for a full development to production environment setup, and I would like to ultimately land in a setup like that. I installed Homestead a while back and struggled with problems it was giving me, so I uninstalled it and went with Cloud9, which would supposedly going to alleviate my server issues and just allow me to debug my newbie code.

If I'm being frankly honest, I am trying to limit the frustration factor as a newer developer. I have spent a lot of time troubleshooting server issues when I would just like to code. I spend enough time troubleshooting my code as I am learning. I quit coding a couple of years ago due to the amount of time I was getting nothing done. I have decided to give it another go, so I am really trying to get a server setup that will do its job long enough for me to get my first full app built. I appreciate your help, but I need simple and working, as quickly as possible. I'm focused on my development environment. I can setup the deployment part later. Thanks again.

bashy's avatar

Cloud9 probably use some sort of reverse proxy and Laravel is adding the port on the end some how. Probably getting printed out for the URL and Laravel just reads it.

@Snapey app.url is only for console related stuff, not front-end so to speak?

Snapey's avatar

@bashy not just console? Anywhere there is no request object off which to create a fully qualified URI. For example creating a button link in an email

WallyJ's avatar

Again, to note. I have another form that works fine. But it's action is Controller@function. The form submission that adds the port 80 is using URL as its action. So it definitely seems to be a Laravel issue, though some things like this is a little bit of server and framework.

WallyJ's avatar

@bashy, Any idea how I could circumvent this? Or should I just look at switching to Homestead? Or even a dedicated server? I've got an old PC in the garage that I could turn into a Linux box and put it on my network. I'm willing to do whatever is most likely to work. The only thing C9 brings to me is being able to develop anywhere I have an internet connection, which isn't really something I HAVE to have at the moment. Thoughts?

WallyJ's avatar

Thanks @jonjie !

Here is my route:

Route::post('/contacts/{contact}/contactnotes', 'ContactnotesController@store');

Here is the Controller:

public function store(Contact $contact, Request $request)
    {
        //add a contactnote to a contact
        $contact->addContactnote(request('contactnotetext'));
        
        return back();
        //return redirect('/contacts/{{$contact->id}}')->with('success', 'Note Added');
    }

Which calls a function in the Contact model:

public function addContactnote($contactnotetext)
    {
            $this->contactnotes()->create(compact('contactnotetext'));
            
    }

Not sure what is causing the issue, but I'm ready to change my development environment, if necessary, to fix it.

Thanks!

WallyJ's avatar

@vmitchell85 , thanks for mentioning the article. If you read all the way to the bottom you can see that I commented on the article because I tried the fixes mentioned in the article concerning my conf file, etc.

I'm just ready to get onto developing again. I may switch back to Homestead on my Windows 10, 64 bit machine. That seems to be a community with a lot of support. I have written Cloud9 and am not receiving a timely response.

WallyJ's avatar

Yes. One form has an action of a controller. The other has a URL as its action.

Jonjie's avatar

Hi @WallyJ .. have you tried to add a name to your route? and use it instead?

WallyJ's avatar

@jonjie , I appreciate you asking, but I know that my code should work, and I don't want to start coding differently just because my development environment demands it of me, when it shouldn't, especially as I'm learning.

To be clear, if I run the server on Cloud9 normally, I have this problem. If I launch the server from the console using the command:

php artisan serve --host $IP --port $PORT  

My app/form works just fine. However, when I launch the server this way, I can no longer reach PHPMyAdmin (I know, the flaming can commence). But I need to use it.

I was hoping that there was something in a config file that I could change to make it work normally, but nothing is working, and trust me, I have read ALL the articles there are to be found on Google. Thanks.

Please or to participate in this conversation.