Skip to content

Commit

Permalink
dev: fix default origins in puter.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Jan 2, 2025
1 parent f1d0f9c commit a8fc466
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/backend/src/modules/selfhosted/SelfHostedModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class SelfHostedModule extends AdvancedBase {
directory: 'src/puter-js',
command: 'npm',
args: ['run', 'start-webpack'],
env: {
PUTER_ORIGIN: ({ global_config: config }) => config.origin,
PUTER_API_ORIGIN: ({ global_config: config }) => config.api_base_url,
},
},
{
name: 'gui:webpack-watch',
Expand Down
4 changes: 2 additions & 2 deletions src/puter-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"main": "index.js",
"scripts": {
"start-server": "npx http-server --cors -c-1",
"start-webpack": "webpack ./src/index.js --output-filename puter.js && webpack ./src/index.js --output-filename puter.dev.js --watch --devtool source-map",
"start-webpack": "webpack && webpack --output-filename puter.dev.js --watch --devtool source-map",
"start": "concurrently \"npm run start-server\" \"npm run start-webpack\"",
"build": "webpack ./src/index.js --output-filename puter.js && { echo \"// Copyright 2024 Puter Technologies Inc. All rights reserved.\"; echo \"// Generated on $(date '+%Y-%m-%d %H:%M')\n\"; cat ./dist/puter.js; } > temp && mv temp ./dist/puter.js"
"build": "webpack && { echo \"// Copyright 2024 Puter Technologies Inc. All rights reserved.\"; echo \"// Generated on $(date '+%Y-%m-%d %H:%M')\n\"; cat ./dist/puter.js; } > temp && mv temp ./dist/puter.js"
},
"keywords": [],
"author": "",
Expand Down
4 changes: 2 additions & 2 deletions src/puter-js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ window.puter = (function() {
// 'web' means the SDK is running in a 3rd-party website.
env;

defaultAPIOrigin = 'https://api.puter.com';
defaultGUIOrigin = 'https://puter.com';
defaultAPIOrigin = globalThis.PUTER_API_ORIGIN ?? 'https://api.puter.com';
defaultGUIOrigin = globalThis.PUTER_ORIGIN ?? 'https://puter.com';

// An optional callback when the user is authenticated. This can be set by the app using the SDK.
onAuth;
Expand Down
18 changes: 18 additions & 0 deletions src/puter-js/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const path = require('path');
const webpack = require('webpack');

console.log('ENV CHECK!!!', process.env.PUTER_ORIGIN, process.env.PUTER_API_ORIGIN);

module.exports = {
entry: './src/index.js',
output: {
filename: 'puter.js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [
new webpack.DefinePlugin({
'globalThis.PUTER_ORIGIN': JSON.stringify(process.env.PUTER_ORIGIN || 'https://puter.com'),
'globalThis.PUTER_API_ORIGIN': JSON.stringify(process.env.PUTER_API_ORIGIN || 'https://api.puter.com'),
}),
],
};

0 comments on commit a8fc466

Please sign in to comment.