Deploy website & ứng dụng web từ Google AI Studio
Xuất bản website hoặc ứng dụng web Google AI Studio của bạn lên Hostinger qua GitHub và luôn giữ nó được cập nhật.
Lộ trình & tài nguyên
Lưu dự án của bạn lên GitHub
Kết nối Google AI Studio với GitHub
Mở website hoặc ứng dụng web bạn đã tạo.
Mở Google AI Studio
https://aistudio.google.com
Your app in Google AI Studio Settings GitHub
Lần đầu? Nhấn "Sign in to GitHub to continue" Nhấn "Install & Authorize" khi được yêu cầu
Settings là biểu tượng bánh răng ở góc trên bên phải. Đã kết nối GitHub rồi? Chuyển sang tác vụ tiếp theo.
Tạo tài khoản GitHub
Only if you don't have one yet.
https://github.com/signup
Tạo repository và lưu
Repository là thư mục dự án của bạn trên GitHub. Hostinger đọc dự án của bạn từ đó.
Nhấn "Create new repository" Nhập tên repository. Phần mô tả là tùy chọn Chọn Private Nhấn "Create GitHub repository" Nhấn "Push changes to GitHub" Chờ đến khi trạng thái hiển thị "GitHub & Google AI Studio are currently in sync"
Thông báo đó xác nhận dự án của bạn đã được lưu.
Thiết lập Hostinger
Đăng ký hosting Hostinger
Bạn cần một gói Hostinger có Web App. Đã có rồi? Mở tài khoản của bạn và chuyển sang bước tiếp theo.
Đăng ký hosting Web App của Hostinger
Chọn gói có Node.js Web App.
USED IN TUTORIAL
Tạo Web App và nhập dự án của bạn
Hostinger Websites Create website Web App
Chọn tên miền của bạn, hoặc một tên miền tạm thời để bắt đầu Chọn Import your Git repository Chọn Continue with GitHub và cấp quyền cho Hostinger nếu được hỏi Chọn repository bạn đã lưu ở Bước 1
Hostinger có thể hiển thị các lựa chọn này dưới dạng câu hỏi từ trợ lý của nó thay vì biểu mẫu. Các lựa chọn vẫn giống nhau.
Kiểm tra cài đặt & deploy
Kiểm tra cài đặt build
Hostinger tự động phát hiện cài đặt build của dự án. Kiểm tra framework được chọn, rồi tiếp tục nếu mọi thứ đều đúng.
Không chắc về cài đặt build?
Tùy chọn. Dán nội dung này vào dự án Google AI Studio của bạn và so sánh câu trả lời với lựa chọn của Hostinger. Nó chỉ đọc các tệp của bạn.
Check this project's deployment settings for Hostinger. This is a read-only check. I am deploying this project to Hostinger as a Web App, imported from GitHub. Hostinger has already suggested build settings, and I want to confirm them against the real project. Inspect the actual project files: package.json, the lockfile, the build configuration and any server file. Do not guess from the preview or from how the app looks. Rules: - Do NOT change, create or delete any file. - Do NOT print the value of any API key or secret. Keep two things separate: - FRONTEND TOOLING: what builds the pages, for example Vite. - SERVER RUNTIME: whether a Node.js server must keep running in production, for example an Express server that serves the app or calls an API. If the project has a Node.js server that must keep running, the Hostinger framework preset should match that server, even when the pages are built with Vite. If there is no server, the preset should match the frontend build tool. Reply in this short format, as plain text and not JSON: Framework preset to choose in Hostinger: Needs a running Node.js backend: Yes or No, with a one-line reason Root directory: only if the app is not at the repository root Package manager: Build command: or "none needed" Server entry file: or "none" Node.js version: only if the project states one, otherwise "not specified" Mismatch to fix: anything that would break on Hostinger, or "none found" If you cannot verify a line from the files, write "not sure" instead of guessing.
Thêm biến môi trường
Không có biến nào được liệt kê? Bỏ qua bước này.
Kiểm tra các biến môi trường Hostinger đã phát hiện Nhập các giá trị dự án của bạn cần Nhấn Continue
Các secret bạn đã lưu trong Google AI Studio không được sao chép sang Hostinger, vì vậy hãy nhập lại chúng ở đây. Nếu dự án dùng Gemini API, hãy tạo khóa trên trang này:
Mở Google AI Studio
API keys page
https://aistudio.google.com/apikey
QUAN TRỌNG
Chỉ nhập khóa API trong Hostinger. Không bao giờ đặt khóa riêng tư vào biến bắt đầu bằng VITE_, và không bao giờ tải tệp .env chứa khóa thật lên GitHub.
Không chắc dự án cần những biến nào?
Tìm các biến dự án của tôi cần
Dán nội dung này vào dự án Google AI Studio của bạn. Nó liệt kê tên các biến mà code của bạn thực sự đọc và không thay đổi gì.
List the environment variables this project needs on Hostinger. This is a read-only check. Search the real source code for process.env and import.meta.env, and read any example environment file. Do not guess and do not invent names. Rules: - Do NOT change, create or delete any file. - Report variable NAMES only. Never print a value. - Do not suggest several names for the same key. Report the one name the code reads. For each variable, give one line: NAME, what it is for, Required or Optional, read on the SERVER or in BROWSER code Do not list variables the hosting platform normally sets by itself, such as NODE_ENV or PORT, unless the code cannot work without a value I must enter. Then add one last line: Private key exposed in browser code: Yes or No Answer Yes if a private key, such as a Gemini API key, is read through a VITE_ variable or otherwise ends up in code that runs in the browser.
Chuyển khóa riêng tư ra khỏi code trình duyệt
Chỉ dùng prompt này nếu bước kiểm tra ở trên cho biết có khóa riêng tư bị lộ trong code trình duyệt. Các biến bắt đầu bằng VITE_ được đưa vào các trang mà ai cũng đọc được.
A private API key in this project is read in browser code. Move it to the server so visitors can never see it. First confirm it from the real files: show me the file and line where browser code reads the key, without printing the key's value. If you cannot find one, stop and tell me. Do not change anything. If it is confirmed, make the smallest change that fixes it, and keep the design and every feature exactly as they are: - Call the API from a server route. Use the Node.js server the project already has. Add a minimal one only if there is none. - Read the key on the server from an environment variable that does NOT start with VITE_. - Make the browser code call my own server route instead of the API directly. - Remove the key from every file that is sent to the browser. Rules: - Never print the key's value. - Do not add a .env file with real keys to the repository. - Do not change unrelated code. When you finish, tell me: - the files you changed - the exact variable name to add in Hostinger - whether the project now needs a running Node.js server, so I can check the framework Hostinger selected
Tiến hành deploy
Kiểm tra cấu hình cuối cùng Nhấn Deploy Chờ build hoàn tất Mở website đang chạy thật
Nếu build thất bại
Sao chép lỗi Hostinger hiển thị, dán vào prompt này và chạy trong dự án Google AI Studio của bạn. Sau đó lưu bản sửa lên GitHub, hoặc thay đổi cài đặt trong Hostinger và deploy lại.
Sửa lỗi deploy thất bại
Tìm nguyên nhân thật từ lỗi của bạn và chỉ sửa đúng chỗ đó.
My project failed to deploy on Hostinger. I deployed it as a Web App imported from GitHub. Here is the exact error from Hostinger's build log: [PASTE THE ERROR HERE] Here is what Hostinger selected: Framework: [PASTE IT HERE] Other build settings, if you can see them: [PASTE THEM HERE, OR DELETE THIS LINE] Find the real cause from this error and the actual project files: package.json, the build configuration and any server file. Do not try random changes, and do not invent a cause the error and the files do not support. If the error is not enough to be sure, tell me what else to copy from Hostinger. - If a Hostinger setting is wrong, tell me exactly which setting to change and to what. Do not change code for that. - If the code or configuration is wrong, fix only that. Keep the design and features the same. - Do not upgrade unrelated packages. - If the log contains a key or password, do not repeat it. Never print the value of an API key or secret. Reply with: Cause: What you changed, or which Hostinger setting to change: What I should do next:
Kiểm tra & cập nhật website
Kiểm tra website đang chạy thật
Mở website đang chạy thật của bạn và đảm bảo các trang cùng tính năng chính đều hoạt động.
Nếu dự án có tính năng AI, đăng nhập hoặc dịch vụ được kết nối, hãy thử cả những phần đó.
Nếu có gì đó không hoạt động trên website đang chạy thật
Sao chép prompt phù hợp với vấn đề của bạn và chạy trong dự án Google AI Studio. Sau đó lưu bản sửa lên GitHub.
Sửa trang trống hoặc trắng
Build đã xong, nhưng website đang chạy thật hiển thị một trang trống.
My project deployed to Hostinger without a build error, but the live website shows a blank page. It works in the Google AI Studio preview. Find what is different in production. Check the real project files for: - errors that only happen in the production build - asset and script paths that break outside the preview, including the base path in the build configuration - a server that does not serve the built files, or serves them from the wrong folder - a server that listens on a fixed port instead of the port the hosting gives it - code that needs an environment variable which is missing in production If I paste errors from the browser console below, start from them: [PASTE ANY BROWSER CONSOLE ERRORS HERE, OR DELETE THIS LINE] Base the fix on what you find in the files and the errors, not on guesses. If you cannot tell the cause, say what else I should copy for you. Keep the design and features exactly the same, and never print the value of an API key or secret. Reply with: Cause: What you changed, or which Hostinger setting to change: What I should do next:
Sửa tính năng AI, đăng nhập hoặc tính năng khác
Website tải được, nhưng một tính năng không hoạt động.
My project is live on Hostinger and the pages load, but this feature does not work: [DESCRIBE THE FEATURE AND WHAT HAPPENS] Any error message I can see: [PASTE IT HERE, OR DELETE THIS LINE] It works in the Google AI Studio preview. Find why it fails in production. Check the real project files for: - the environment variables this feature reads. List their NAMES so I can confirm each one has a value in Hostinger - code that depends on Google AI Studio's own environment or secrets and has no equivalent on Hostinger - API calls that need a running Node.js server, in case the project was deployed without one - addresses that point to the preview or to localhost instead of the live domain - for sign-in or outside services: settings that must list my live domain Never ask me for the value of an API key or secret, and never print one. Never move a private key into browser code or into a VITE_ variable to make the feature work. Do not invent a cause the files and the error do not support. Keep the design and other features the same. Reply with: Cause: What you changed, or what I must set in Hostinger or in the outside service: What I should do next:
Sửa lỗi 404 ở trang con
Trang chủ hoạt động, nhưng khi mở hoặc tải lại trang khác thì hiện 404.
My project is live on Hostinger. The home page works, but opening or refreshing an inner page shows a 404 page. Inspect how this project handles routes: the router in the frontend, and the server file if there is one. - If the project runs its own Node.js server, make that server return the app's main page for routes the frontend router handles, without breaking API routes or static files. - If the project has no server, do not add one. Tell me what the hosting must do for these routes and which Hostinger setting to check. Change only what this problem needs. Keep the design and features the same. Reply with: Cause: What you changed, or which Hostinger setting to change: What I should do next:
Cập nhật website của bạn
Mỗi bản cập nhật đều đi theo cùng một đường: Google AI Studio → GitHub → Hostinger → Website đang chạy thật.
Thực hiện một thay đổi nhỏ trong Google AI Studio Mở Settings, rồi GitHub Nhấn "Push changes to GitHub" Chờ đến khi dự án được đồng bộ Chờ Hostinger deploy bản cập nhật Tải lại website đang chạy thật và kiểm tra thay đổi
Hostinger tự deploy bản cập nhật miễn là repository GitHub của bạn vẫn được kết nối và tính năng deploy tự động đang bật cho Web App của bạn.