You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel-Vue项目发布帖子时出现Source Map 404错误求助

Let's tackle your issues one by one to get everything working smoothly:

Fixing the Bootstrap.js.map 404 Error

That source map error happens because your browser is trying to load the Bootstrap source map file (bootstrap.js.map) to help with debugging, but either the file doesn't exist at the expected path or it's not being served correctly. Here are two ways to fix this:

  • Quick fix: Disable source maps temporarily
    If you don't need source maps right now and just want to eliminate the error, you can turn them off in your build configuration (I’m assuming you’re using Laravel Mix since your code lives in resources/js). Update your webpack.mix.js file:

    mix.js('resources/js/app.js', 'public/js')
       .sourceMaps(false); // Disable source map generation
    

    Then recompile your assets with npm run dev (for development) or npm run prod (for production).

  • Proper fix: Ensure the source map is correctly served
    If you want to keep source maps for debugging:

    1. Check if bootstrap.js.map exists in your node_modules/bootstrap/dist/js folder. If it’s missing, reinstall Bootstrap with npm install bootstrap --save.
    2. Confirm your build tool is copying the source map to your public/js directory. Laravel Mix does this automatically by default, but if you have custom webpack rules, double-check that source map files are being output correctly.
    3. Verify the source map reference in your compiled app.js file. At the end of the file, you should see a comment like //# sourceMappingURL=bootstrap.js.map — make sure this path matches where the actual .map file lives in your public/js folder.
Fixing Potential Issues in Your Vue/Axios Code

Looking at your app.js code, there are a couple of things that might cause problems down the line:

  • Incorrect Axios Request URL
    Your current request URL is 'myid.web/home/addPost' — this will make the browser send a request to http://{mywebsite}/myid.web/home/addPost, which is probably not your actual API endpoint. Instead, use a root-relative path if your route is on the same domain:

    axios.post('/home/addPost', { content: this.content })
    
  • Incomplete Catch Block
    You have console.log... in your catch handler, which is invalid syntax. Fix it to properly log errors so you can debug any request issues:

    .catch(function(error){
        console.log(error); // Log full error details to debug
    })
    
  • Improve Context with Arrow Functions
    For cleaner code and to keep access to the Vue instance's this inside your promise handlers, use arrow functions:

    addPost(){
        axios.post('/home/addPost', { content: this.content })
        .then(response => {
            console.log(response);
            this.content = ''; // Optional: Clear input after successful post
        })
        .catch(error => {
            console.log(error);
        })
    }
    

After making these changes, recompile your assets and test again — both the source map error and any potential request issues should be resolved.

内容的提问来源于stack exchange,提问作者Biswas Sampad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:08:42