dev: fix default origins in puter.js

This commit is contained in:
KernelDeimos 2025-01-02 16:23:02 -05:00
parent f1d0f9cd1f
commit a8fc4669e8
4 changed files with 26 additions and 4 deletions

View File

@ -50,6 +50,10 @@ class SelfHostedModule extends AdvancedBase {
directory: 'src/puter-js', directory: 'src/puter-js',
command: 'npm', command: 'npm',
args: ['run', 'start-webpack'], 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', name: 'gui:webpack-watch',

View File

@ -5,9 +5,9 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start-server": "npx http-server --cors -c-1", "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\"", "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": [], "keywords": [],
"author": "", "author": "",

View File

@ -30,8 +30,8 @@ window.puter = (function() {
// 'web' means the SDK is running in a 3rd-party website. // 'web' means the SDK is running in a 3rd-party website.
env; env;
defaultAPIOrigin = 'https://api.puter.com'; defaultAPIOrigin = globalThis.PUTER_API_ORIGIN ?? 'https://api.puter.com';
defaultGUIOrigin = 'https://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. // An optional callback when the user is authenticated. This can be set by the app using the SDK.
onAuth; onAuth;

View File

@ -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'),
}),
],
};