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

Laravel与VueJS页面加载异常求助:页面无限循环且/js/landing.js请求长期Pending

Hey there, let's tackle this tricky issue step by step. I've dealt with similar WSL + Laravel + Vue problems before, so here are some practical troubleshooting directions and fixes to try:

排查方向与解决方案

1. Fix WSL File System Permission & Location Issues

WSL and Windows file system interactions often cause permission or file watch glitches.

  • If your Laravel project is stored in a Windows directory (like /mnt/c/Users/...), move it to WSL's native file system (e.g., ~/projects/your-app). Then re-run npm install, npm run watch, and php artisan serve—this often resolves file access bottlenecks.
  • If you don't want to move the project, fix permissions in your project root:
    sudo chmod -R 755 storage bootstrap/cache
    
    This ensures Laravel has proper read/write access to critical directories.

2. Verify npm Watch Compilation Status

Sometimes npm run watch fails silently, leaving an incomplete or missing landing.js file.

  • Check the terminal running npm run watch for errors (like ESLint violations, missing dependencies). Fix any compilation issues first.
  • Run npm run dev manually to force a full compile, then check if public/js/landing.js exists and has a reasonable file size (not empty or tiny).

3. Double-Check Laravel Mix Configuration

Incorrect Mix settings can lead to wrong asset paths or missing output files.

  • Open webpack.mix.js and confirm your Vue compilation config looks correct:
    mix.js('resources/js/landing.js', 'public/js')
       .vue();
    
  • Ensure there's no custom public path override that's sending compiled assets to the wrong directory.

4. Rule Out Browser Cache & Proxy Interference

Browser cache or proxy tools can block asset requests and cause pending statuses.

  • Access the page in your browser's incognito mode to bypass cached resources.
  • Close any proxy tools (like Fiddler or Charles) running on your Windows machine, then refresh the page.

5. Fix WSL Port Forwarding & Network Glitches

The default php artisan serve setup on WSL sometimes has port forwarding issues.

  • Get your WSL IP by running hostname -I in the WSL terminal, then start the server with that IP:
    php artisan serve --host=YOUR_WSL_IP --port=8000
    
    Access the page using this IP (e.g., http://192.168.x.x:8000) instead of localhost.
  • Temporarily disable Windows Firewall to check if it's blocking the 8000 port.

6. Check for Vue Route Infinite Loops

The page infinite loop might stem from Vue routing logic, not just asset loading.

  • Open resources/js/landing.js and inspect your route guards (like beforeEach). Look for logic that causes endless redirects, such as:
    router.beforeEach((to, from, next) => {
      // Bad example: no exit condition, forces constant redirect
      next('/login');
    });
    
  • Ensure your route guards have clear conditions to stop the loop.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 12:32:42