Closed sebastianpisula closed 1 year ago
Hi @sebastianpisula. Thanks for bringing up this issue.
The template used to create the application configures vite
in the frontend
to redirect the requests to the backend
https://github.com/Shopify/shopify-frontend-template-react/blob/f720a83458f3e83db4f2b5e85644345fc658cd32/vite.config.js#L54:L61
When you run the app using the CLI, there are some env variables set when the backend and frontend processes are run.
PORT
, SERVER_PORT
, BACKEND_PORT
You should configure symfony
to run the http server listening to one of those three env variables.
In your logs the CLI has run the backend using the random port 65384
and the symfony server seems to run using the port 8000
by default. That's the reason you can see the error
2023-03-06 18:13:49 | frontend | 7:13:49b/PM [vite] http proxy error:
2023-03-06 18:13:49 | frontend | Error: connect ECONNREFUSED 127.0.0.1:65384
2023-03-06 18:13:49 | frontend | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
I don't know anything about symfony
but maybe configuring the toml
like this could do the trick `dev = "symfony server:start --port=${PORT}"
Please, let me know if this works for you.
Thanks, great idea but I have errors:
── external error ──────────────────────────────────────────────────────────────
Error coming from `symfony server:start --port=${PORT}`
Command failed with exit code 1: symfony server:start --port=${PORT}
Incorrect usage: invalid value "${PORT}" for flag -port: parse error
Description:
Run a local web server
Usage:
symfony local:server:start [options]
Options:
--dir=value Project directory
--allow-http Prevent auto-redirection from HTTP to HTTPS
--document-root=value Project document root (auto-configured by default)
--passthru=value Project passthru index (auto-configured by default)
--port=value Preferred HTTP port [default: 8000]
--daemon, -d Run the server in the background
--no-humanize Do not format JSON logs
--p12=value Name of the file containing the TLS certificate to
use in p12 format
--no-tls Use HTTP instead of HTTPS
--use-gzip Use GZIP
--tls-key-log-file=value Destination for TLS master secrets in NSS key log
format [$SSLKEYLOGFILE]
--help, -h Show help
Help:
The local web server is optimized for local development and MUST never be used
in a production setup.
────────────────────────────────────────────────────────────────────────────────
I modified web/frontend/vite.config.js and I changed line #17 from:
target: `http://127.0.0.1:${process.env.BACKEND_PORT}`,
to:
target: `http://127.0.0.1:8000`,
and in tome file without port:
dev = "symfony server:start"
and works!
But I not sure that hardcoded proxy is good way. What you think ?
@sebastianpisula , sorry for the wrong tip. I don't know anything about how symfony
sets the port, you should do a little research and set it to one of the three env variables PORT, SERVER_PORT, BACKEND_PORT
That temporary solution is going to work but it's specific for your scenario. Using the env variable it's the only way to have a generic solution
Closing as it sounds like this was a specific config issue. Feel free to re-open with more context if this affects more use cases. Thank you!
Please confirm that you have:
In which of these areas are you experiencing a problem?
App
Expected behavior
My app should be open
Actual behavior
In web directory I removed Laravel app and I try to configure Symfony app. I added files to directory and I changed web/shopify.web.toml file like this:
I use command
npm run dev
and url doesn't works.Stack trace
Reproduction steps
1. 2. 3.
Operating System
MacOS Ventura
Shopify CLI version (check your project's
package.json
if you're not sure)3.44.1
Shell
zsh
Node version (run
node -v
if you're not sure)19.7.0
What language and version are you using in your application?
PHP 8.1