Giter Club home page Giter Club logo

Comments (8)

fpcimmino avatar fpcimmino commented on May 17, 2024 1

I had the same problem.
It worked for me to add BASE_API=/api to my .env and run "npm run dev".

I hope to work for you.

from laravue.

tuandm avatar tuandm commented on May 17, 2024

The correct route should be /api/auth/login, please check if your .env has those lines:

BASE_API=/api
MIX_BASE_API="${BASE_API}"

from laravue.

budirec avatar budirec commented on May 17, 2024

I think the issue is the env variable is not available.
Doing console.log(process.env) gives me error
process is undefined

from laravue.

prawn185 avatar prawn185 commented on May 17, 2024

@budirec So how would you solve this?

from laravue.

budirec avatar budirec commented on May 17, 2024

For now what I do is hardcode /api in https://github.com/tuandm/laravue/blob/master/resources/js/utils/request.js#L7

But I think there should be better way to fix this, and need to investigate why the env var is not feed to the js

from laravue.

tuandm avatar tuandm commented on May 17, 2024

That setting is on your .env, please check example in https://github.com/tuandm/laravue/blob/master/.env.example

BASE_API=/api
MIX_BASE_API="${BASE_API}"

This MIX_BASE_API value will be transfered to

  baseURL: process.env.MIX_BASE_API,

Detail here: https://laravel.com/docs/5.8/mix#environment-variables

from laravue.

budirec avatar budirec commented on May 17, 2024

yeah, I have that in my .env but it wasn't available in the js file
process.env is undefined

`
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
BASE_API=/api

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_BASE_API="${BASE_API}"
MIX_WP_DOMAIN="${WP_DOMAIN}"
`

from laravue.

tuandm avatar tuandm commented on May 17, 2024

Changing .env required npm run again

from laravue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.