Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing dump does not include port for local dev #440

Closed
lampelk opened this issue Jun 1, 2022 · 1 comment · Fixed by #463
Closed

Routing dump does not include port for local dev #440

lampelk opened this issue Jun 1, 2022 · 1 comment · Fixed by #463

Comments

@lampelk
Copy link

lampelk commented Jun 1, 2022

When dumping routes on local dev:

fos:js-routing:dump --format=json --target=public/js/routes.json

The json output does not include port if the web server is running with a port (e.g. 8080):

{
  "base_url": "",
  "routes": {
    "app_home": {
      "tokens": [["text", "\/home"]],
      "defaults": [],
      "requirements": [],
      "hosttokens": [],
      "methods": [],
      "schemes": []
    }
  },
  "prefix": "",
  "host": "localhost",
  "port": "",
  "scheme": "http",
  "locale": ""
}

Expected result:

"port": 8080

I found this issue when trying to generate absolute URLs:

Routing.generate('app_home', /* your params */, true)

Result:

http://localhost/home

Expected result:

http://localhost:8080/home

Environment:
php: 8.0.2
symfony: 6.0*
friendsofsymfony/jsrouting-bundle: 3.1.1

Related (maybe?): #391

@bobvandevijver
Copy link
Contributor

bobvandevijver commented Jul 19, 2023

You can try setting the HTTP_HOST env var when generating the file to localhost:8080. Are you using the older fos-routing npm package, or the one bootstrapped with the bundle? Version doesn't matter, you should always set the HTTP_HOST when generating the file from the command line, or call a method on the Router instance. I created an MR to clarify this in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants