Skip to content

Port Change Bug Fix #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/studio/src/components/Modals/Settings/Project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,22 @@ const ProjectTab = observer(() => {
};

const handleUpdateUrl = (url: string) => {
let port = url.split(':').pop();

try {
const parsedUrl = new URL(url);
port = parsedUrl.port;
} catch (error) {
console.error('Invalid URL');
return;
}
projectsManager.updatePartialProject({
url,
commands: {
...project?.commands,
run: 'npx next dev -p ' + port,
build: 'npx next build -p ' + port,
},
});
projectsManager.editorEngine?.canvas.saveFrames(
projectsManager.editorEngine?.canvas.frames.map((frame) => ({
Expand Down Expand Up @@ -70,6 +84,7 @@ const ProjectTab = observer(() => {
id="url"
value={url}
onChange={(e) => handleUpdateUrl(e.target.value)}
onBlur={() => projectsManager.runner?.restart()}
className="w-2/3"
/>
</div>
Expand Down
5 changes: 3 additions & 2 deletions apps/studio/src/lib/projects/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ export class CreateManager {
createProject(projectPath: string) {
const projectName = 'New Project';
const projectUrl = 'http://localhost:3000';
const port = 3000;
const projectCommands = {
install: 'npm install',
run: 'npm run dev',
build: 'npm run build',
run: 'npx next dev -p ' + port,
build: 'npx next build -p ' + port,
};

return this.projectsManager.createProject(
Expand Down