laravel-enso / enso

Laravel Vue SPA, Bulma themed. For demo login use `admin@laravel-enso.com` & `password` -
https://www.laravel-enso.com
MIT License
1.08k stars 277 forks source link

Can't get yarn serve running #263

Closed mauthi closed 4 years ago

mauthi commented 4 years ago

This is a bug.

Prerequisites

Description

I use the following config:

Expected behavior

Browser should show login screen after calling http://localhost:8001/login

Actual behavior

I get the following error for: http://localhost:8001/api/meta Proxy error: Could not proxy request /api/meta from localhost:8001 to http://localhost:8080/ (ECONNRESET).

mauthi commented 4 years ago

Any feedback here? It's not urgent but I would like to know if you know the problem or if I need a different approach.

Another question: I used yarn run watch for < 3.7.x - is there something comparable available in the meantime?

aocneanu commented 4 years ago

Hi @mauthi,

I don't know about the problem, we're not using docker for running Enso projects.

client/.env's API_URL should point to your backend api, not the frontend application, where you access the login page. You can test if you have figured the right one by accessing in the brower http://localhost:8001/api/meta direction. If the backend url is correct you should see in the brower

{"meta":{"appName":"You App","appUrl":"http:\/\/erp.test\/","extendedDocumentTitle":true,"showQuote":true},"i18n":{"en":{"Email":"Email","Password":"Password","Remember me":"Remember me","Forgot password":"Forgot password","Login":"Login","Send a reset password link":"Send a reset password link","Repeat Password":"Repeat Password","Success":"Success","Error":"Error"}},"routes":{"login":{"uri":"api\/login","methods":["POST"],"domain":null},"password.email":{"uri":"api\/password\/email","methods":["POST"],"domain":null},"password.reset":{"uri":"api\/password\/reset","methods":["POST"],"domain":null}}}
aocneanu commented 4 years ago

Another question: I used yarn run watch for < 3.7.x - is there something comparable available in the meantime?

yarn serve -> much more powerful than the past yarn run watch

mauthi commented 4 years ago

I don't know about the problem, we're not using docker for running Enso projects.

@bytebuddha if I can remember correctly did you add the docker stuff to enso? Can you maybe help me with my problem?

wendivoid commented 4 years ago

Yes i did, i'm not really sure what is causing this error. Could you try mapping 8080 on the host machine to 80 on the docker container? this was how i was using it and i had no problems. Can you try this and see if there error changes?

mauthi commented 4 years ago

What did you enter for client/.env's API_URL? Can you please send me both your docker config and your client/.env file?

Thx

wendivoid commented 4 years ago

@mauthi I'm at work now, if you would give me about 6 hr's, i can get home and get the requested information. I'll post the files here as soon as i can get to my development project

wendivoid commented 4 years ago

I was able to setup a new development project using this as the docker-compose.yml

version: '3'

services:
  php:
    build: ./docker
    container_name: vstekscrm
    ports:
      - 8000:80
    volumes:
      - ./docker/vhosts.conf:/etc/apache2/sites-enabled/000-default.conf
      - ./:/var/www/html
    depends_on:
      - mysqldb

  mysqldb:
    image: mysql:5.7.21
    container_name: vstekscrm-${DB_CONNECTION}
    restart: always
    env_file:
      - .env
    environment:
      - MYSQL_DATABASE=${DB_DATABASE}
      - MYSQL_USER=${DB_USERNAME}
      - MYSQL_PASSWORD=${DB_PASSWORD}
      - MYSQL_ALLOW_EMPTY_PASSWORD=true
    ports:
      - 3306:3306
    volumes:
      - /var/lib/mysql

  myadmin:
    image: phpmyadmin/phpmyadmin:4.7
    container_name: vstekscrm-phpmyadmin
    ports:
      - 8081:80
    environment:
      - PMA_ARBITRARY=1
      - PMA_HOST=vstekscrm-${DB_CONNECTION}
    restart: always
    depends_on:
      - mysqldb

and this as .env

APP_NAME=Enso
APP_ENV=local
APP_KEY=base64:rqgh6P417QsyiOM6loi/zPXEiMI0NFWm9S6hvcoXfkI=
APP_DEBUG=true
APP_URL=http://localhost:8000

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=mysqldb
DB_PORT=3306
DB_DATABASE=enso
DB_USERNAME=root
DB_PASSWORD=

DB_TENANT_DATABASE=tenant

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_CONNECTION=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=log
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

LOGIN_ATTEMPTS_PER_MINUTE=5
PASSWORD_LIFETIME=0
PASSWORD_LENGTH=6
PASSWORD_UPPER_CASE_CHARACTERS=0
PASSWORD_NUMERIC_CHARACTERS=0
PASSWORD_SPECIAL_CHARACTERS=0

ENSO_API_TOKEN=adrian

APP_URL is set to http://localhost:8000 and in docker-compose port 8000 on the host is mapped to port 80 on the virtual machine.

Tested with a new clone of laravel-enso

mauthi commented 4 years ago

Thx, I changed my configs to your values - now the project is running without errors.

In yarn server I get the following message:

  App running at:
  - Local:   http://localhost:8080/

  It seems you are running Vue CLI inside a container.
  Access the dev server via http://localhost:<your container's external mapped port>/

If I unterstood everything correct now HMR should work so if I change a *.vue File the change should be visible in browser without changing anything? Unfortunately this is not working in my case.


If I change mapping in docker-compose.yml from 8000:80 to 8000:8080 I get the following message in console: [HMR] Waiting for update signal from WDS...

But after that I get the error: GET http://localhost:8000/api/meta 500 (Internal Server Error)

And on console I get:

Proxy error: Could not proxy request /api/meta from localhost:8000 to http://localhost:8000/.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).
wendivoid commented 4 years ago

Ok i haven't used the dev server with laravel enso before. Try using the command 'yarn watch' this will only rebuild the project on file change but not start the dev server. This is how i have been developing. Unfortunalty you still need to refresh the browser manually this way though

mauthi commented 4 years ago

Ok thx, I thought you are using HMR with docker. I now yarn build --watch which should be the same - but it would be better without reloading.

If I find a solution I will post it here.

mauthi commented 4 years ago

I found a solution - the following config works for me:

docker-compose.yml --> maps my local port 8000 to container's port 8080

    ports:
      - 8000:8080

client/.env --> needed because my apache in docker runs on port 80 API_URL=http://localhost:80/

Now Hot-Reloading works like expected (changes are applied to browser without reloading)