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

Abhaytec's avatar

Unable to access my laravel api from vue

i have this laravel-vue project that i was asked to setup at work and the vue is served using webpack, and everytime that i try to access the laravel route api, this is the response i get from the network tab of the chrome browser Request URL: https://domain.test/v1/crm/login Referrer Policy: strict-origin-when-cross-origin Provisional headers are shown Learn more Accept: application/json, text/plain, / Content-Type: application/json Referer: https://domain.test:8080/ and even if i try to access the api endpoint using my postman and browser all i get back is Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. Apache/2.4.51 (Win64) PHP/7.2.34 Server at prepcrm.test Port 80

this is the webpack config // const ManifestPlugin = require('webpack-manifest-plugin') const {VueLoaderPlugin} = require('vue-loader') const webpack = require('webpack') const HtmlWebpackPlugin = require('html-webpack-plugin')

const path = require('path') const itemsResPath = 'resources/crm' const publicPath = 'public/crm' const env = process.env.NODE_ENV const port = process.env.PORT || 8080

const isProduction = env === 'production'

const isDevServer = process.argv.some(v => v.includes('webpack-dev-server'));

module.exports = { mode: env, devtool: isProduction ? undefined : 'cheap-module-eval-source-map', entry: path.resolve(__dirname, itemsResPath, 'js/index.js'), output: { path: path.resolve(__dirname, publicPath), filename: '[name].[hash:6].js', chunkFilename: 'js/[name].[contenthash:6].js', publicPath: isDevServer ? https://localhost:${port}/ : '/crm/' }, devServer: { hot: true, host: 'prepcrm.test', https: true, noInfo: false, contentBase: path.join(__dirname, publicPath), publicPath: '/', watchOptions: { poll: false } }, module: { rules: [ { test: /.vue$/, use: 'vue-loader' }, { test: /.(s[ac]|c)ss$/, include: [ /node_modules/, path.resolve(__dirname, 'resources') ], use: [ 'vue-style-loader', { loader: 'css-loader', options: { modules: false, localIdentName: '[local]_[hash:base64:8]' } }, 'sass-loader' ] }, { test: /.jsx?$/, exclude: /node_modules/, use: 'babel-loader' }, { test: /.(png|jpe?g|gif)$/, loader: 'file-loader', options: { name: 'images/[name].[ext]?[hash:6]', publicPath: isDevServer ? '/' : '/crm' } }, { test: /.(woff2?|ttf|eot|svg|otf)$/, loader: 'file-loader', options: { name: 'fonts/[name].[ext]?[hash:6]', publicPath: isDevServer ? '/' : '/crm', basePath: 'crm', writeToFileEmit: true } } ] }, plugins: [ new VueLoaderPlugin(), new webpack.DefinePlugin({ PRODUCTION: env === 'production' }), new HtmlWebpackPlugin({ filename: isDevServer ? 'index.html' : path.resolve(__dirname, 'resources/views/index.blade.php'), template: path.resolve(__dirname, 'resources/crm/index.html') }) ], resolve: { alias: { 'vue$': 'vue/dist/vue.common.js', 'my-lib': path.resolve(__dirname, itemsResPath + '/js/lib'), components: path.resolve(__dirname, itemsResPath + '/js/components'), package: path.resolve(__dirname, './package.json'), assets: path.resolve(__dirname, itemsResPath + '/js/assets'), views: path.resolve(__dirname, itemsResPath + '/js/views/'), 'vuex-store': path.resolve(__dirname, itemsResPath + '/js/store') }, extensions: ['*', '.js', '.jsx', '.vue'] }, optimization: { splitChunks: { cacheGroups: { vendor: { test: /node_modules/, // you may add "vendor.js" here if you want to name: 'vendor', chunks: 'initial', enforce: true } } }, runtimeChunk: { name: 'manifest' } } }

0 likes
12 replies
aurelianspodarec's avatar

I wonder, what if you try to request a simple API JSON response that says:

{"name": "Joe"}

See if that works.

I assume you're requesting the login page?

What is the exact request that you sent?

Abhaytec's avatar

@aurelianspodarec have tried to do that too, the response i got is Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.51 (Win64) PHP/7.2.34 Server at prepcrm.test Port 80

Abhaytec's avatar

@aurelianspodarec i created this Route::get('/yea', function () { return 'hellow'; }); in my laravel api and try to access it in my postman using this url prepcrm.test/api/yea and it gives that internal server error message prepcrm.test is my virtualhost name

aurelianspodarec's avatar

@Abhaytec I wonder if this could be an issue https://stackoverflow.com/questions/36731082/dynamic-virtual-host-gives-500-error-with-laravel

It does work for me, and I do receive a response with your code on my postman:

<!-- https://laravel-news.com/creating-helpers -->hollow

What are you using for the environment? Are you on a Mac/Windows?

And if on WIndows, what are you using? laragon? Xamp? mamp? or? Did you do PHP artisan serve (maybe not needed)

Also, I would try starting a new project and see if it works on a fresh install - if it works then there's probably something blocking in your code.

aurelianspodarec's avatar

@Abhaytec I just read, you're using wamp.

I think you do need to do php artisan serve did you do that?

Also, what does your logs say here?

More information about this error may be available in the server error log. Apache/2.4.51 (Win64) PHP/7.2.34 Server at prepcrm.test Port 80
Abhaytec's avatar

the issue i have not is that, i can access my web route request and response from postman, but cannot on my api route..

Abhaytec's avatar

@aurelianspodarec what i meant is that i have the block of codes below written in my web routes and api routes Route::get('hello', function(){ return 'hello'; }); in my postman, if i make a request 127.0.0.1/hello, it shows the response but if i make a request 127.0.0.1/api/hello, it says not 404 not found... I hope you get my questions now

Please or to participate in this conversation.