ข้ามไปที่เนื้อหาหลัก

แก้ไขปัญหา Laravel+Vite redirect ไปที่ path build

 

ก่อนหน้านี้ติดปัญหาเรื่องการพัฒนาเว็บแอพลิเคชันด้วย Laravel และ Vuejs โดยใช้ Vite ควบคู่ในการพัฒนา Frontend ตอนรัน npm run dev ก็ดูเหมือนจะใช้งานได้ปกติ

แต่พอมาลอง build ดูปรากฏว่าตัว application คอย redirect ไปที่ path /build ตลอดเลย พอหาข้อมูล ไปๆ มาๆ ก็เจอว่าตอนที่เขียนเราใช้ router ของฝั่ง vuejs ซึ่งทำเป็น SPA

const router = createRouter({

    history: createWebHistory(import.meta.env.BASE_URL),

});

จากโค๊ดด้านบนนี่แหละที่ มึนอยู่หลาย ชั่วโมง แก้ง่ายๆ ที่สุด คือทำแบบนี้

const router = createRouter({

    history: createWebHistory(),

});

เข้าใจว่า import.meta.env.BASE_URL ค่า default น่าจะเป็น /build ถ้าเอาออกจะช่วยแก้ไขปัญหาได้ แต่ยังไม่ได้ลองว่าถ้าเราไปกำหนด env ตัวนี้ขึ้นมาก็อาจจะช่วยแก้ไขปัญหาได้ด้วยหรือเปล่า?

VITE_BASE_URL="/"

ใครลองแล้วได้ผลมาคอมเม้นกันด้วยนะ วันนี้ไปก่อนละ


ความคิดเห็น

  1. winbuzz keeps account access and platform guidance simple for users who want a smoother online betting experience. The winbuzz login section allows visitors to enter quickly and also check common topics like winbuzz apk download, winbuzz game, and app support. The site presents payment details in a plain and readable way, making deposits and withdrawals feel easier to manage. With its direct structure and user-friendly tone, winbuzz remains a practical choice for players searching for easy Cricket ID access.

    ตอบลบ
  2. Many sports and casino users prefer websites that present details in a clean and understandable format, and dafawin does that well. It brings together helpful guidance on login access, banking steps, and betting options so visitors can quickly find what they need. The content style feels direct and useful, especially for users who value easy support language. Alongside these updates, the site also shares Cricket ID information, making it easier for players to move from inquiry to active participation with confidence.

    ตอบลบ
  3. If someone wants easy-to-follow betting support and casino access information, 1win is a useful place to begin. The website shares key details about deposits, withdrawals, and user access in a simple format that helps visitors move forward faster. It keeps the experience focused on practical needs rather than unnecessary complexity. Many users also come to review updated Cricket ID information, which plays an important role for those interested in sports betting and connected online gaming options.

    ตอบลบ
  4. Sports betting enthusiasts visiting khelo 24 can review information covering cricket access, casino games, deposits, withdrawals, and different betting options. Users seeking a Cricket ID can find helpful guidance designed to explain relevant access details clearly. The website keeps essential information straightforward, allowing visitors to understand account and payment processes more easily. With practical service updates and accessible explanations, users can explore cricket betting and other online gaming information from a convenient source.

    ตอบลบ
  5. The sky exchange login page can be useful for visitors seeking information about cricket-related accounts, sports betting, casino games, and general payment processes. Users can review common deposit and withdrawal guidance while learning about available account access options. People looking for a Cricket ID can also find helpful cricket-specific details. By keeping service information clear and accessible, the website helps users better understand platform features before exploring different cricket, sports, and casino services.

    ตอบลบ

แสดงความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

การเพิ่ม Font ภาษาไทยอื่นๆ เข้าไปใช้งานใน MPDF

เนื่องมาจากผมได้มีโอกาสจับงานที่ต้องแปลงหน้าเว็บให้เป็น PDF ลองๆ หาข้อมูลก็ไปเจอเจ้าตัวนี้ MPDF  ซึ่งจริงๆ แล้วก็มีให้ใช้งานอีกหลายๆ ตัว สาเหตุที่เลือกใช้งานตัวนี้เพราะมัน ค่อนข้างจะติดตั้ง และใช้งานง่าย และยังสามารถอ้างอิง CSS เข้ามาช่วยจัดหน้าตาใน PDF ได้อีกด้วย ซึ่งผลที่ได้เพี้ยนไปจากตัวจริงไม่มากครับ แต่ที่ทำให้เลือกใช้งานเพราะการเพิ่มฟ้อนท์ภาษาไทย เข้าไปนั้นค่อนข้างง่ายครับ เลยจะขอมาแนะนำดังนี้

การเขียน Force download ด้วย PHP

การทำ Force download ด้วย PHP นั้น ไม่ไช่เรื่องใหม่อะไร มีการเขียนโค้ดด้วยลักษณะนี้อยู่บ่อยๆ แต่ผมต้องนำมาแปะเป็นทริคเล็กน้อยกันตัวเองลืมครับ ประโยชน์ของมันคือในกรณีที่เราไม่สามารถเข้าไปจัดการ Apache config ได้เราสามารถใช้วิธีนี้แทนได้